Distributing Python scripts without .py extension

If I write a package in Python for distribution, and I put some scripts as executables in scriptsof setup.py, is there a standard way to make them not have the * .py extension? Is it enough to just make files that do not have the extension .py or something else is needed? Will .py remove a file name that violates any functionality related to Python tools like setup.py/ distutils etc.? Thank.

+5
source share
3 answers

If you need compatibility with Windows, either do not remove the extension .py, or use the setuptools parameter entry_points, which automatically generates the appropriate script system files, for example, to set the function pip.main()as a script, pippoints to setup.py:

  entry_points=dict(console_scripts=['pip=pip:main', 
          'pip-%s=pip:main' % sys.version[:3]]),

It makes sense to use entry_pointsit even if you do not need Windows compatibility, because it generates the right shebang for you, which points to a specific python interpreter (where the generic one #! /usr/bin/env pythonwill be wrong).

+2
source

.py , AFAICT. , pip, easy_install .. - shebang . , , Windows.

+3

script , .py . script Python :

  • , : $ python nameofyourscript
  • , , , shebang script, Python. #!/usr/bin/env python.

shebang , .

script script, .

0

All Articles