mirror of
https://github.com/frappe/bench.git
synced 2024-09-29 07:19:05 +00:00
refactor(minor): Dependency resolving
* Added a requirements method under BenchSetup * Resolve Frappe dependencies prior to other apps * Fixed issues with missing path in update_env_pip
This commit is contained in:
parent
84d1b209ba
commit
4655f6e785
@ -285,6 +285,10 @@ class BenchSetup(Base):
|
|||||||
|
|
||||||
logger.log("backups were set up")
|
logger.log("backups were set up")
|
||||||
|
|
||||||
|
def requirements(self):
|
||||||
|
from bench.utils.bench import update_requirements
|
||||||
|
update_requirements(bench=self.bench)
|
||||||
|
|
||||||
|
|
||||||
class BenchTearDown:
|
class BenchTearDown:
|
||||||
def __init__(self, bench):
|
def __init__(self, bench):
|
||||||
|
@ -6,6 +6,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from json.decoder import JSONDecodeError
|
from json.decoder import JSONDecodeError
|
||||||
|
import typing
|
||||||
|
|
||||||
# imports - third party imports
|
# imports - third party imports
|
||||||
import click
|
import click
|
||||||
@ -15,6 +16,10 @@ import bench
|
|||||||
from bench.utils import get_process_manager, which, log, exec_cmd, get_bench_name, get_cmd_output
|
from bench.utils import get_process_manager, which, log, exec_cmd, get_bench_name, get_cmd_output
|
||||||
from bench.exceptions import PatchError, ValidationError
|
from bench.exceptions import PatchError, ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
if typing.TYPE_CHECKING:
|
||||||
|
from bench.bench import Bench
|
||||||
|
|
||||||
logger = logging.getLogger(bench.PROJECT_NAME)
|
logger = logging.getLogger(bench.PROJECT_NAME)
|
||||||
|
|
||||||
|
|
||||||
@ -38,41 +43,46 @@ def get_venv_path():
|
|||||||
|
|
||||||
|
|
||||||
def update_env_pip(bench_path):
|
def update_env_pip(bench_path):
|
||||||
env_py = get_env_cmd("python")
|
env_py = get_env_cmd("python", bench_path=bench_path)
|
||||||
exec_cmd(f"{env_py} -m pip install -q -U pip")
|
exec_cmd(f"{env_py} -m pip install -q -U pip")
|
||||||
|
|
||||||
|
|
||||||
def update_requirements(bench_path="."):
|
def update_requirements(bench: "Bench" = None, bench_path="."):
|
||||||
from bench.app import install_app
|
from bench.app import install_app
|
||||||
from bench.bench import Bench
|
|
||||||
|
|
||||||
bench = Bench(bench_path)
|
if not bench:
|
||||||
|
from bench.bench import Bench
|
||||||
|
|
||||||
|
bench = Bench(bench_path)
|
||||||
|
|
||||||
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.insert(0, "frappe")
|
||||||
|
|
||||||
print("Updating env pip...")
|
print("Updating env pip...")
|
||||||
|
update_env_pip(bench.name)
|
||||||
update_env_pip(bench_path)
|
|
||||||
|
|
||||||
print(f"Installing {len(apps)} applications...")
|
print(f"Installing {len(apps)} applications...")
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
install_app(app, bench_path=bench_path, skip_assets=True, restart_bench=False)
|
install_app(app, bench_path=bench.name, skip_assets=True, restart_bench=False)
|
||||||
|
|
||||||
|
|
||||||
def update_python_packages(bench_path="."):
|
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")
|
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.insert(0, "frappe")
|
||||||
|
|
||||||
print("Updating Python libraries...")
|
print("Updating Python libraries...")
|
||||||
|
|
||||||
update_env_pip(bench_path)
|
update_env_pip(bench_path)
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
click.secho(f"\nInstalling python dependencies for {app}", fg="yellow")
|
|
||||||
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")
|
||||||
bench.run(f"{env_py} -m pip install -q -U -e {app_path}")
|
bench.run(f"{env_py} -m pip install -q -U -e {app_path}")
|
||||||
|
|
||||||
|
|
||||||
@ -410,8 +420,7 @@ To avoid seeing this warning, set shallow_clone to false in your common_site_con
|
|||||||
|
|
||||||
if requirements:
|
if requirements:
|
||||||
print("Setting up requirements...")
|
print("Setting up requirements...")
|
||||||
update_requirements(bench_path=bench_path)
|
bench.setup.requirements()
|
||||||
update_node_packages(bench_path=bench_path)
|
|
||||||
|
|
||||||
if patch:
|
if patch:
|
||||||
print("Patching sites...")
|
print("Patching sites...")
|
||||||
|
Loading…
Reference in New Issue
Block a user