mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
fix: Use execve and set envvars instead of execv
Changed from execv to execve with empty env dict because bench commands on macOS 10.14.6 PY3.9.0a4 fails with "Error while finding module specification for 'frappe.utils.bench_helper' (ModuleNotFoundError: No module named 'frappe')" This error has come up in the past too. I'm now suspecting it has something to do with the current process passing on it's environment variables to the process that's going to replace it, which causes these issues. Note that direct execution of the commands without the bench wrapper worked fine although via bench failed with the specified error
This commit is contained in:
parent
b0ccb6efbe
commit
530a980ef7
@ -109,19 +109,19 @@ def change_uid():
|
|||||||
def old_frappe_cli(bench_path='.'):
|
def old_frappe_cli(bench_path='.'):
|
||||||
f = get_frappe(bench_path=bench_path)
|
f = get_frappe(bench_path=bench_path)
|
||||||
os.chdir(os.path.join(bench_path, 'sites'))
|
os.chdir(os.path.join(bench_path, 'sites'))
|
||||||
os.execv(f, [f] + sys.argv[2:])
|
os.execve(f, [f] + sys.argv[2:], {})
|
||||||
|
|
||||||
|
|
||||||
def app_cmd(bench_path='.'):
|
def app_cmd(bench_path='.'):
|
||||||
f = get_env_cmd('python', bench_path=bench_path)
|
f = get_env_cmd('python', bench_path=bench_path)
|
||||||
os.chdir(os.path.join(bench_path, 'sites'))
|
os.chdir(os.path.join(bench_path, 'sites'))
|
||||||
os.execv(f, [f] + ['-m', 'frappe.utils.bench_helper'] + sys.argv[1:])
|
os.execve(f, [f] + ['-m', 'frappe.utils.bench_helper'] + sys.argv[1:], {})
|
||||||
|
|
||||||
|
|
||||||
def frappe_cmd(bench_path='.'):
|
def frappe_cmd(bench_path='.'):
|
||||||
f = get_env_cmd('python', bench_path=bench_path)
|
f = get_env_cmd('python', bench_path=bench_path)
|
||||||
os.chdir(os.path.join(bench_path, 'sites'))
|
os.chdir(os.path.join(bench_path, 'sites'))
|
||||||
os.execv(f, [f] + ['-m', 'frappe.utils.bench_helper', 'frappe'] + sys.argv[1:])
|
os.execve(f, [f] + ['-m', 'frappe.utils.bench_helper', 'frappe'] + sys.argv[1:], {})
|
||||||
|
|
||||||
|
|
||||||
def get_frappe_commands():
|
def get_frappe_commands():
|
||||||
|
@ -453,12 +453,15 @@ def get_process_manager():
|
|||||||
|
|
||||||
|
|
||||||
def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False):
|
def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False):
|
||||||
|
env = os.environ
|
||||||
program = get_process_manager()
|
program = get_process_manager()
|
||||||
|
|
||||||
if not program:
|
if not program:
|
||||||
raise Exception("No process manager found")
|
raise Exception("No process manager found")
|
||||||
os.environ['PYTHONUNBUFFERED'] = "true"
|
|
||||||
|
env['PYTHONUNBUFFERED'] = "true"
|
||||||
if not no_dev:
|
if not no_dev:
|
||||||
os.environ['DEV_SERVER'] = "true"
|
env['DEV_SERVER'] = "true"
|
||||||
|
|
||||||
command = [program, 'start']
|
command = [program, 'start']
|
||||||
if concurrency:
|
if concurrency:
|
||||||
@ -470,7 +473,7 @@ def start(no_dev=False, concurrency=None, procfile=None, no_prefix=False):
|
|||||||
if no_prefix:
|
if no_prefix:
|
||||||
command.extend(['--no-prefix'])
|
command.extend(['--no-prefix'])
|
||||||
|
|
||||||
os.execv(program, command)
|
os.execve(program, command, env=env)
|
||||||
|
|
||||||
|
|
||||||
def get_git_version():
|
def get_git_version():
|
||||||
|
Loading…
Reference in New Issue
Block a user