What's the minimal directory structure to make

2020-04-18 08:38发布

问题:

one_file.py contains some general functions, classes, and a main().

I'd like to make it pip installable with a command line script that calls the main() function.

What's a directory structure and setup.py that will do this?

回答1:

You can get away with this with just a setup.py and your module--no additional directories. In your setup.py just use setup(..., py_modules=['one_file'], ...) (you might want to check on the exact spelling). To install the script you can use the console_scripts entry-point:

from setuptools import setup
setup(
    name='one-file',
    version='1.0',
    py_modules=['one_file'],
    entry_points={'console_scripts': ['one-file = one_file:main']}
)