问题描述
我正在尝试创建可执行的python脚本以在命令行上使用(目的是上传到PyPi)。为此,我需要添加一个shebang。
如何为不同的操作系统获取合适的shebang?
旁注:我看了一个在conda环境中的可执行文件(cookiecutter)的示例。我注意到shebang是
#!/home/<my-name>/miniconda/envs/<some-environment>/bin/python3.6
Conda在这里做得很聪明吗?点子呢?
解决方法
Linux shebang works just fine on Windows with modern versions of Python and its dedicated py.exe
launcher。只需始终使用Linux shebang。 Conda的shebang旨在启动非常特定的Python安装;通常,您要使用默认的最新Python 3安装,而您想要的是Linux上的PATH
查找方法(Windows上是仿真方法)。
使用setuptools console_scripts
功能。
它将为您生成Shebang