Re: Removing *.py ending from python script filenames

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

just subscribed here for other reasons and stumbled across this, but since I know about Python packaging:

The "right way" (in as, understood and common to the Python community) to distribute Python scripts that are supposed to be installed and run from command line is to first package up the Python stuff as a proper Python package and then follow

http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point

For example

https://github.com/crossbario/crossbar/blob/master/setup.py#L98

This will install a proper wrapper with no extension. It will also allow to use the Python stuff from Python by mere importing the wrapped function.

(cpy3_1) oberstet@thinkpad-t430s:~/scm/crossbario/crossbario-organize$ which crossbar
/home/oberstet/python/cpy3_1/bin/crossbar

(cpy3_1) oberstet@thinkpad-t430s:~/scm/crossbario/crossbario-organize$ cat `which crossbar`
#!/home/oberstet/python/cpy3_1/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'crossbar','console_scripts','crossbar'
__requires__ = 'crossbar'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('crossbar', 'console_scripts', 'crossbar')()
    )
(cpy3_1) oberstet@thinkpad-t430s:~/scm/crossbario/crossbario-organize$

Cheers,
/Tobias

PS: Also, please consider publishing the Python package to PyPI too (eg for people that find distro packages annoying, eg because they use virtualenv or what)
--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux