Reputation: 281
I am trying to create an executable python script for use on the command line (aim is to upload to PyPi). For this I need to add a shebang.
#!/usr/bin/env python3
#! python3
How do I get the appropriate shebang for the different OS's?
Side note: I looked at an example of an executable file (cookiecutter) I have in a conda environment. I noticed the shebang was
#!/home/<my-name>/miniconda/envs/<some-environment>/bin/python3.6
Is Conda do something smart here? What about pip?
Upvotes: 1
Views: 77
Reputation: 1040
use setuptools console_scripts
feature.
It will generate the shebang for you
Upvotes: 1
Reputation: 155363
The Linux shebang works just fine on Windows with modern versions of Python and its dedicated py.exe
launcher. Just use the Linux shebang consistently. Conda's shebang is designed to launch a very specific Python installation; in general, you want to use the default up-to-date Python 3 install, and the PATH
lookup approach on Linux (and emulation on Windows) is what you want.
Upvotes: 2