0

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:

  1. Which system is appropiate for a Python 3(.2) program? distribute? distutils? setuptools?

  2. 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.

  3. How can I do 2. in a platfom-independent way?

Thanks! :)

asked Nov 14, 2012 at 13:12

1 Answer 1

1
  1. Use either distribute or setuptools, the former is a fork of the latter, with some improvements and better documentation. Either one is a big step up from distutils, which is part of the python standard library.

  2. 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 foo and bar would be scripts that you can call on the command line. The indicated function will be called with sys.argv[1:] as the first and only argument.

  3. Let the installation tools take care of that; it works fine on Windows. :-)

answered Nov 14, 2012 at 13:21
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.