2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-13 16:56:33 +00:00

refactor(minor): python packages setup

This commit is contained in:
Gavin D'souza 2021-11-26 12:47:29 +05:30
parent 4798992abf
commit 6081690d7b
3 changed files with 13 additions and 8 deletions

View File

@ -354,11 +354,11 @@ def install_app(
bench = Bench(bench_path)
conf = bench.conf
quiet_flag = "" if verbose else "-q"
quiet_flag = "" if verbose else "--quiet"
app_path = os.path.realpath(os.path.join(bench_path, "apps", app))
cache_flag = "--no-cache-dir" if no_cache else ""
bench.run(f"{bench.python} -m pip install {quiet_flag} -U -e {app_path} {cache_flag}")
bench.run(f"{bench.python} -m pip install {quiet_flag} --upgrade -e {app_path} {cache_flag}")
if conf.get("developer_mode"):
install_python_dev_dependencies(apps=app)

View File

@ -237,12 +237,12 @@ class BenchSetup(Base):
virtualenv = get_venv_path()
if not os.path.exists(self.bench.python):
self.run(f"{virtualenv} -q env -p {python}")
self.run(f"{virtualenv} env -p {python}")
self.run(f"{self.bench.python} -m pip install -U pip")
self.pip()
if os.path.exists(frappe):
self.run(f"{self.bench.python} -m pip install -U -e {frappe}")
self.run(f"{self.bench.python} -m pip install --upgrade -e {frappe}")
@step(title="Setting Up Bench Config", success="Bench Config Set Up")
def config(self, redis=True, procfile=True):
@ -262,6 +262,11 @@ class BenchSetup(Base):
setup_procfile(self.bench.name, skip_redis=not redis)
def pip(self):
"""Updates env pip; assumes that env is setup
"""
return self.run(f"{self.bench.python} -m pip install --upgrade pip")
def logging(self):
from bench.utils import setup_logging

View File

@ -83,12 +83,12 @@ def update_python_packages(bench_path="."):
apps.insert(0, "frappe")
print("Updating Python libraries...")
update_env_pip(bench_path)
bench.setup.pip()
for app in apps:
app_path = os.path.join(bench_path, "apps", app)
click.secho(f"\nInstalling python dependencies for {app}", fg="yellow")
bench.run(f"{bench.python} -m pip install -U -e {app_path}")
bench.run(f"{bench.python} -m pip install --upgrade -e {app_path}")
def update_node_packages(bench_path="."):
@ -226,7 +226,7 @@ def migrate_env(python, backup=False):
venv_creation = exec_cmd(f"{virtualenv} --python {python} {pvenv}")
apps = " ".join([f"-e {os.path.join('apps', app)}" for app in bench.apps])
packages_setup = exec_cmd(f"{pvenv} -m pip install -q -U {apps}")
packages_setup = exec_cmd(f"{pvenv} -m pip install --upgrade {apps}")
logger.log(f"Migration Successful to {python}")
except Exception: