2

I'm trying to package one of my projects with setuptools. This project deploys an executable script configured in the "setup.py":

scripts=['bin/check_mailq.py'],

The first line of the "check_mailq.py" file is:

#!/usr/bin/env python

If I execute "setup.py install", the first line is replaced with the python path of the machine/virtualenv. BTW if I package the project for pypi with the command:

python setup.py bdist_egg bdist_wheel upload

and then install it with pip in my production machine, the python path is wrong.

#!/home/kbyte/pynagmailplugins/venv/bin/python

instead of (example):

#!/opt/production_venv/bin/python

What's wrong?

Kbyte
  • 138
  • 6

1 Answers1

4

Distutils modifies the shebang line with the path to the python you use to run distutils with, so this is expected behavior. I believe it is setup this way to make sure all the library dependencies needed by your script are in the same python version.

If pip is causing the problem, it was likely installed when in a different virtualenv/with a different python.

FWIW, you can run: python setup.py build --executable="/usr/bin/env python" to manually keep the shebang as is.

See also: Don't touch my shebang!, https://github.com/hpcugent/vsc-mympirun-scoop/issues/7

Community
  • 1
  • 1
lemonhead
  • 5,328
  • 1
  • 13
  • 25
  • Great, the `--executable` parameter is the answer. BTW I've to put `--executable="python"` because "/usr/bin/env python" is not enough. Thank you! – Kbyte Jul 30 '15 at 19:38