databio / bulker

Manager for multi-container computing environments
https://bulker.io
BSD 2-Clause "Simplified" License
24 stars 2 forks source link

python console scripts are problematic #41

Open nsheff opened 4 years ago

nsheff commented 4 years ago

If you put python into bulker, then console scripts are getting a bad shebang... the shebang corresponds to the path within the container, of course, but since we actually want to run the script from outside the container (in the bulker environment), that shebang is incorrect. It needs instead to be the path to the bulkerized python interpreter.

One way to solve this ad hoc is to replace the shebang after-the-fact, like this would do for the console script for looper:

py3=`which python3` sed -i s"|/usr/local/bin/python3|$py3|" `which looper`

Another possibility is to not rely on console scripts, but instead alias python3 -m looper (assuming the packages are set up correctly with __main__.py files)

Neither of these solutions is really satisfactory. I think it's just a fundamental problem with the way python console scripts work, which tightly couple the python path installing the package and the script itself. In this case, I want to break that coupling because the install is happening in a container, while the running will initiate outside the container (though it eventually ends in the container as well). This is not possible with the current python system.

See also:

https://stackoverflow.com/questions/50557963/why-does-pip-install-seem-to-change-the-interpreter-line-on-some-machines

https://github.com/pepkit/looper/issues/224