开发者

python setup.py install changes script interpreter

I have a Python package that includes a f开发者_StackOverflow中文版ew scripts in a scripts/ folder. My setup.py file includes::

#!/usr/bin/env python

from distutils.core import setup

scripts = ['script1', 'script2', 'script3']

setup(name='Test',
      version='0.1.0',
      packages=['test'],
      scripts=['scripts/' + x for x in scripts]
     )

Each script contains the line::

#!/usr/bin/env python

at the top. However, when I run python setup.py install this line gets changed to::

#!/usr/bin/python

automatically in the installed scripts. Is there a way to avoid this? The reason that this is a problem for me is because I am using virtualenv, and so the correct path for the Python executable should be::

#/Users/user/.virtualenvs/default/bin/python

so I'd rather it left the interpreter set to::

#!/usr/bin/env python

Thanks for any advice!


The install scripts checks, where the python is installed and changes this python to the proper one. It does it on every machine, where your package is installed.

From docs:

Scripts are files containing Python source code, intended to be started from the command line. Scripts don’t require Distutils to do anything very complicated. The only clever feature is that if the first line of the script starts with #! and contains the word “python”, the Distutils will adjust the first line to refer to the current interpreter location. By default, it is replaced with the current interpreter location. The --executable (or -e) option will allow the interpreter path to be explicitly overridden.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜