If I build a package with python setup.py bdist_wheel
, the resulting package expands the shebangs in the scripts listed in setup.py via setup(scripts=["script/path"])
to use the absolute path to my python executable #!/home/f483/dev/storj/storjnode/env/bin/python
.
This is obviously a problem as anyone using the wheel will not have that setup. It does not seem to make a difference what kind of shebang I am using.
This should not normally happen. I'd suggest either:
Upgrading pip / wheel / setuptools and checking if it was maybe a bug.
Rechecking that the current shbang is something generic in the script. For example #!/usr/bin/env python
Here's a way I can't reproduce the issue:
paster --no-interactive test
mkdir test/scripts
echo -e "#!/usr/bin/env python\nprint('test')" > test/scripts/s.py
# add scripts/s.py to test/setup.py
cd test; python setup.py bdist_wheel
If you unpack that wheel, s.py
will have an invalid/placeholder shbang #!python
, but during actual installation, it will be changed to the proper system/virtualenv path.
I finally narrowed it down and found the problem.
Here the exact steps to reproduce the problem and the solution.
Use a valid shebang in a script thats added in setup.py. In my case #!/usr/bin/env python
Create a virtualenv with virtualenv -p /usr/bin/python2 env
and activate with source env/bin/activate
.
Install the package with python setup.py install
to the virtualenv.
Build the wheel with python setup.py bdist_wheel
.
The problem is installing the package to the virtualenv in step 3. If this is not done the shebang is not expanded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With