diff --git a/bench/cli.py b/bench/cli.py index eea1acc7..f5891d0a 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -1,6 +1,6 @@ import click import os, sys, logging, json, pwd, subprocess -from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, find_parent_bench +from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, is_dist_editable, find_parent_bench from bench.app import get_apps from bench.config.common_site_config import get_config from bench.commands import bench_command @@ -19,6 +19,9 @@ def cli(): change_dir() change_uid() + if is_dist_editable("bench"): + log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3) + if len(sys.argv) > 2 and sys.argv[1] == "frappe": return old_frappe_cli() diff --git a/bench/utils.py b/bench/utils.py index fc9ecbb4..6fb985fc 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -1095,6 +1095,15 @@ def migrate_env(python, backup=False): raise +def is_dist_editable(dist): + """Is distribution an editable install?""" + for path_item in sys.path: + egg_link = os.path.join(path_item, dist + '.egg-link') + if os.path.isfile(egg_link): + return True + return False + + def find_parent_bench(path): """Checks if parent directories are benches""" if is_bench_directory(directory=path):