mirror of
https://github.com/frappe/bench.git
synced 2025-01-24 07:28:25 +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")
|
||||
|
||||
def requirements(self):
|
||||
from bench.utils.bench import update_requirements
|
||||
update_requirements(bench=self.bench)
|
||||
|
||||
|
||||
class BenchTearDown:
|
||||
def __init__(self, bench):
|
||||
|
@ -6,6 +6,7 @@ import re
|
||||
import subprocess
|
||||
import sys
|
||||
from json.decoder import JSONDecodeError
|
||||
import typing
|
||||
|
||||
# imports - third party imports
|
||||
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.exceptions import PatchError, ValidationError
|
||||
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from bench.bench import Bench
|
||||
|
||||
logger = logging.getLogger(bench.PROJECT_NAME)
|
||||
|
||||
|
||||
@ -38,41 +43,46 @@ def get_venv_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")
|
||||
|
||||
|
||||
def update_requirements(bench_path="."):
|
||||
def update_requirements(bench: "Bench" = None, bench_path="."):
|
||||
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.remove("frappe")
|
||||
apps.insert(0, "frappe")
|
||||
|
||||
print("Updating env pip...")
|
||||
|
||||
update_env_pip(bench_path)
|
||||
update_env_pip(bench.name)
|
||||
|
||||
print(f"Installing {len(apps)} applications...")
|
||||
|
||||
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="."):
|
||||
from bench.bench import Bench
|
||||
|
||||
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.remove("frappe")
|
||||
apps.insert(0, "frappe")
|
||||
|
||||
print("Updating Python libraries...")
|
||||
|
||||
update_env_pip(bench_path)
|
||||
|
||||
for app in apps:
|
||||
click.secho(f"\nInstalling python dependencies for {app}", fg="yellow")
|
||||
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}")
|
||||
|
||||
|
||||
@ -410,8 +420,7 @@ To avoid seeing this warning, set shallow_clone to false in your common_site_con
|
||||
|
||||
if requirements:
|
||||
print("Setting up requirements...")
|
||||
update_requirements(bench_path=bench_path)
|
||||
update_node_packages(bench_path=bench_path)
|
||||
bench.setup.requirements()
|
||||
|
||||
if patch:
|
||||
print("Patching sites...")
|
||||
|
Loading…
x
Reference in New Issue
Block a user