How can I include a shell command line argument for the python package installed for pip?

So, for a python package, how to include a command line argument from an installed package? Here is an example for a package called mrbob:

$ pip install mrbob
$ mrbob DoSomethingFunction

How to enable command line parameter and new shell command for python package?

+4
source share
2 answers

With setuptoolsdefine entry point console_script:

setup(
    # other arguments here...
    entry_points={
        'console_scripts': [
            'mrbob = my_package.some_module:main_func',
        ]
    }
)

For more information, see the automatic creation of a script in documents setuptools.

C distutilsuse scripts:

setup(...,
      scripts=['scripts/mrbob']
      )

See installing scripts in documents for more details distutils.

+3
source

mrbob bin :

/Library/Frameworks/Python.framework/Versions/2.7/bin/

$PATH, .

0

Source: https://habr.com/ru/post/1625549/


All Articles