-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Currently, run()
directly exec
's the setuptools-generated entrypoint script, which in turn finds the correct python
by including the full path to the {env_dir}/bin/python
executable as a shebang line.
Shebang lines are limited to 127 characters, which is very easy to exceed with appenv, since the venv hash already takes up 64.
I propose to specify the python executable in appenv itself, instead of relying on the shebang line, like this:
diff --git a/batou b/batou
index 8f03df7..455def7 100755
--- a/batou
+++ b/batou
@@ -200,7 +200,10 @@ def run(argv, meta_args):
env_dir = _prepare(meta_args)
# Allow called programs to find out where the wrapper lives
os.environ['APPENV_BASEDIR'] = meta_args.base
- os.execv(os.path.join(env_dir, 'bin', meta_args.appname), argv)
+ interpreter = os.path.join(env_dir, 'bin', 'python')
+ entrypoint = os.path.join(env_dir, 'bin', meta_args.appname)
+ argv[0] = interpreter
+ argv.insert(1, entrypoint)
+ os.execv(interpreter, argv)
This works fine with batou, but argv[0]
is not preserved (since at least under Debian we must set argv[0]
to the venv/bin/python, otherwise the venv is not recognized and the spawned python runs with the system site-packages), so programs that are interested in that will have trouble. Not sure if that's something we have to worry about, though.