Skip to content Skip to sidebar Skip to footer

Distribute Executable Module

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 i

Solution 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. :-)

Post a Comment for "Distribute Executable Module"