I developed a program consisting of a package which is executable (i.e. two files x/__init__.py and x/__main__.py), so I can execute it using python -m x, if the package resides in the python path.
I never tried to distribute Python packages/modules and I don't have any experience in that field (yet)... I already noticed that there are many different systems and now I have three questions:
Which system is appropiate for a Python 3(.2) program? distribute? distutils? setuptools?
How can I add kind of a "wrapper script" to the distribution that executes the module directly without the hassle with
python -m ...so that the user can just type x (of course the actual name is a bit more unique :) on the shell.How can I do 2. in a platfom-independent way?
Thanks! :)
1 Answer 1
Use either
distributeorsetuptools, the former is a fork of the latter, with some improvements and better documentation. Either one is a big step up fromdistutils, which is part of the python standard library.You want a console script, for which you define an entry point:
entry_points = { 'console_scripts': [ 'foo = my_package.some_module:main_func', 'bar = other_module:some_func', ],where
fooandbarwould be scripts that you can call on the command line. The indicated function will be called withsys.argv[1:]as the first and only argument.Let the installation tools take care of that; it works fine on Windows. :-)
Comments
Explore related questions
See similar questions with these tags.