2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 17:24:41 +00:00

Merge branch 'develop' into staging

This commit is contained in:
Ankush Menat 2022-11-29 13:16:31 +05:30
commit 7e4f0eaf1f

View File

@ -175,12 +175,17 @@ def migrate_env(python, backup=False):
nvenv = "env" nvenv = "env"
path = os.getcwd() path = os.getcwd()
python = which(python) python = which(python)
virtualenv = which("virtualenv")
if not virtualenv:
raise FileNotFoundError("`virtualenv` not found. Install it and try again.")
pvenv = os.path.join(path, nvenv) pvenv = os.path.join(path, nvenv)
if python.startswith(pvenv):
# The supplied python version is in active virtualenv which we are about to nuke.
click.secho(
"Python version supplied is present in currently sourced virtual environment.\n"
"`deactiviate` the current virtual environment before migrating environments.",
fg="yellow",
)
sys.exit(1)
# Clear Cache before Bench Dies. # Clear Cache before Bench Dies.
try: try:
config = bench.conf config = bench.conf
@ -212,18 +217,24 @@ def migrate_env(python, backup=False):
shutil.move(dest, target) shutil.move(dest, target)
# Create virtualenv using specified python # Create virtualenv using specified python
venv_creation, packages_setup = 1, 1 def _install_app(app):
app_path = f"-e {os.path.join('apps', app)}"
exec_cmd(f"{pvenv}/bin/python -m pip install --upgrade {app_path}")
try: try:
logger.log(f"Setting up a New Virtual {python} Environment") logger.log(f"Setting up a New Virtual {python} Environment")
venv_creation = exec_cmd(f"{virtualenv} --python {python} {pvenv}") exec_cmd(f"{python} -m venv {pvenv}")
apps = " ".join([f"-e {os.path.join('apps', app)}" for app in bench.apps]) # Install frappe first
packages_setup = exec_cmd(f"{pvenv} -m pip install --upgrade {apps}") _install_app("frappe")
for app in bench.apps:
if str(app) != "frappe":
_install_app(app)
logger.log(f"Migration Successful to {python}") logger.log(f"Migration Successful to {python}")
except Exception: except Exception:
if venv_creation or packages_setup: logger.warning("Python env migration Error", exc_info=True)
logger.warning("Migration Error") raise
def validate_upgrade(from_ver, to_ver, bench_path="."): def validate_upgrade(from_ver, to_ver, bench_path="."):