问题:pip3 install
和setuptools
以一种意想不到的方式阻止了shebang shell脚本。我试图了解它是如何工作的以及如何控制它。
会发生什么:在macOS 10.13上,我使用macports安装的Python 3.5。我已经开发了Python 3软件包,目前可以通过以下简单的过程进行安装:
git clone https://github.com/project/mypackage.git
cd mypackage
sudo pip3 install .
包的setup.py
包含以下内容:
scripts = ['bin/somescript'],
每个这样的脚本都有以下第一行:
#!/usr/bin/env python3
今天,我发现pip3
在安装过程中以一种依赖于脚本的第二行的方式管理shebang线。特别是,如果我的脚本的开头是这样的,
#!/usr/bin/env python3
#
# some comments here
然后pip3 install
用#!/usr/bin/X11/python3
替换第一行,这在我的系统上恰好是完全错误的。但是,如果我的脚本的开头是这样的:
#!/usr/bin/env python3
# some comments here
pip3 install
用不同的(此时正确)路径#!/opt/local/bin/python3
替换shebang行。
我的问题:基本上,为什么会发生这种情况?
pip3 install
如何选择使用哪种解释器?/usr/bin/X11/python3
(我的系统上不存在)?