mirror of
https://github.com/frappe/bench.git
synced 2024-11-16 01:57:08 +00:00
feat(minor): Bench.python property that points to env python
This commit is contained in:
parent
27128c7c18
commit
d63a9883e0
@ -181,8 +181,7 @@ class App(AppMeta):
|
|||||||
|
|
||||||
@step(title="Uninstalling App {repo}", success="App {repo} Uninstalled")
|
@step(title="Uninstalling App {repo}", success="App {repo} Uninstalled")
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
env_python = get_env_cmd("python", bench_path=self.bench.name)
|
self.bench.run(f"{self.bench.python} -m pip uninstall -y {self.repo}")
|
||||||
self.bench.run(f"{env_python} -m pip uninstall -y {self.repo}")
|
|
||||||
|
|
||||||
|
|
||||||
def add_to_appstxt(app, bench_path="."):
|
def add_to_appstxt(app, bench_path="."):
|
||||||
@ -355,12 +354,11 @@ def install_app(
|
|||||||
|
|
||||||
bench = Bench(bench_path)
|
bench = Bench(bench_path)
|
||||||
conf = bench.conf
|
conf = bench.conf
|
||||||
python_path = get_env_cmd("python", bench_path=bench_path)
|
quiet_flag = "" if verbose else "-q"
|
||||||
quiet_flag = "-q" if not verbose else ""
|
|
||||||
app_path = os.path.realpath(os.path.join(bench_path, "apps", app))
|
app_path = os.path.realpath(os.path.join(bench_path, "apps", app))
|
||||||
cache_flag = "--no-cache-dir" if no_cache else ""
|
cache_flag = "--no-cache-dir" if no_cache else ""
|
||||||
|
|
||||||
bench.run(f"{python_path} -m pip install {quiet_flag} -U -e {app_path} {cache_flag}")
|
bench.run(f"{bench.python} -m pip install {quiet_flag} -U -e {app_path} {cache_flag}")
|
||||||
|
|
||||||
if conf.get("developer_mode"):
|
if conf.get("developer_mode"):
|
||||||
install_python_dev_dependencies(apps=app)
|
install_python_dev_dependencies(apps=app)
|
||||||
|
@ -4,7 +4,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
from typing import MutableSequence, TYPE_CHECKING
|
from typing import List, MutableSequence, TYPE_CHECKING
|
||||||
|
|
||||||
# imports - module imports
|
# imports - module imports
|
||||||
import bench
|
import bench
|
||||||
@ -63,18 +63,21 @@ class Bench(Base, Validator):
|
|||||||
self.excluded_apps_txt = os.path.join(self.name, "sites", "excluded_apps.txt")
|
self.excluded_apps_txt = os.path.join(self.name, "sites", "excluded_apps.txt")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def shallow_clone(self):
|
def python(self) -> str:
|
||||||
|
return get_env_cmd("python", bench_path=self.name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def shallow_clone(self) -> bool:
|
||||||
config = self.conf
|
config = self.conf
|
||||||
|
|
||||||
if config:
|
if config:
|
||||||
if config.get("release_bench") or not config.get("shallow_clone"):
|
if config.get("release_bench") or not config.get("shallow_clone"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if get_git_version() > 1.9:
|
return get_git_version() > 1.9
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def excluded_apps(self):
|
def excluded_apps(self) -> List:
|
||||||
try:
|
try:
|
||||||
with open(self.excluded_apps_txt) as f:
|
with open(self.excluded_apps_txt) as f:
|
||||||
return f.read().strip().split("\n")
|
return f.read().strip().split("\n")
|
||||||
@ -82,7 +85,7 @@ class Bench(Base, Validator):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sites(self):
|
def sites(self) -> List:
|
||||||
return [
|
return [
|
||||||
path
|
path
|
||||||
for path in os.listdir(os.path.join(self.name, "sites"))
|
for path in os.listdir(os.path.join(self.name, "sites"))
|
||||||
@ -146,11 +149,10 @@ class BenchApps(MutableSequence):
|
|||||||
return f.write("\n".join(self.apps))
|
return f.write("\n".join(self.apps))
|
||||||
|
|
||||||
def initialize_apps(self):
|
def initialize_apps(self):
|
||||||
cmd = f"{get_env_cmd('python', bench_path=self.bench.name)} -m pip freeze"
|
|
||||||
is_installed = lambda app: app in installed_packages
|
is_installed = lambda app: app in installed_packages
|
||||||
|
|
||||||
try:
|
try:
|
||||||
installed_packages = get_cmd_output(cmd=cmd, cwd=self.bench.name)
|
installed_packages = get_cmd_output(f"{self.bench.python} -m pip freeze", cwd=self.bench.name)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.apps = []
|
self.apps = []
|
||||||
return
|
return
|
||||||
@ -232,16 +234,15 @@ class BenchSetup(Base):
|
|||||||
- install frappe python dependencies
|
- install frappe python dependencies
|
||||||
"""
|
"""
|
||||||
frappe = os.path.join(self.bench.name, "apps", "frappe")
|
frappe = os.path.join(self.bench.name, "apps", "frappe")
|
||||||
env_python = get_env_cmd("python", bench_path=self.bench.name)
|
|
||||||
virtualenv = get_venv_path()
|
virtualenv = get_venv_path()
|
||||||
|
|
||||||
if not os.path.exists(env_python):
|
if not os.path.exists(self.bench.python):
|
||||||
self.run(f"{virtualenv} -q env -p {python}")
|
self.run(f"{virtualenv} -q env -p {python}")
|
||||||
|
|
||||||
self.run(f"{env_python} -m pip install -q -U pip")
|
self.run(f"{self.bench.python} -m pip install -U pip")
|
||||||
|
|
||||||
if os.path.exists(frappe):
|
if os.path.exists(frappe):
|
||||||
self.run(f"{env_python} -m pip install -q -U -e {frappe}")
|
self.run(f"{self.bench.python} -m pip install -U -e {frappe}")
|
||||||
|
|
||||||
@step(title="Setting Up Bench Config", success="Bench Config Set Up")
|
@step(title="Setting Up Bench Config", success="Bench Config Set Up")
|
||||||
def config(self, redis=True, procfile=True):
|
def config(self, redis=True, procfile=True):
|
||||||
|
@ -77,7 +77,6 @@ def update_python_packages(bench_path="."):
|
|||||||
from bench.bench import Bench
|
from bench.bench import Bench
|
||||||
|
|
||||||
bench = Bench(bench_path)
|
bench = Bench(bench_path)
|
||||||
env_py = get_env_cmd("python", bench_path=bench.name)
|
|
||||||
|
|
||||||
apps = [app for app in bench.apps if app not in bench.excluded_apps]
|
apps = [app for app in bench.apps if app not in bench.excluded_apps]
|
||||||
apps.remove("frappe")
|
apps.remove("frappe")
|
||||||
@ -89,7 +88,7 @@ def update_python_packages(bench_path="."):
|
|||||||
for app in apps:
|
for app in apps:
|
||||||
app_path = os.path.join(bench_path, "apps", app)
|
app_path = os.path.join(bench_path, "apps", app)
|
||||||
click.secho(f"\nInstalling python dependencies for {app}", fg="yellow")
|
click.secho(f"\nInstalling python dependencies for {app}", fg="yellow")
|
||||||
bench.run(f"{env_py} -m pip install -q -U -e {app_path}")
|
bench.run(f"{bench.python} -m pip install -U -e {app_path}")
|
||||||
|
|
||||||
|
|
||||||
def update_node_packages(bench_path="."):
|
def update_node_packages(bench_path="."):
|
||||||
@ -117,13 +116,12 @@ def install_python_dev_dependencies(bench_path=".", apps=None):
|
|||||||
elif apps is None:
|
elif apps is None:
|
||||||
apps = [app for app in bench.apps if app not in bench.excluded_apps]
|
apps = [app for app in bench.apps if app not in bench.excluded_apps]
|
||||||
|
|
||||||
env_py = get_env_cmd("python")
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
app_path = os.path.join(bench_path, "apps", app)
|
app_path = os.path.join(bench_path, "apps", app)
|
||||||
dev_requirements_path = os.path.join(app_path, "dev-requirements.txt")
|
dev_requirements_path = os.path.join(app_path, "dev-requirements.txt")
|
||||||
|
|
||||||
if os.path.exists(dev_requirements_path):
|
if os.path.exists(dev_requirements_path):
|
||||||
bench.run(f"{env_py} -m pip install -q -r {dev_requirements_path}")
|
bench.run(f"{bench.python} -m pip install -r {dev_requirements_path}")
|
||||||
|
|
||||||
|
|
||||||
def update_yarn_packages(bench_path="."):
|
def update_yarn_packages(bench_path="."):
|
||||||
|
Loading…
Reference in New Issue
Block a user