How do I use setuptools or distutils to distribute a script as opposed to a Python package? -


in past, tutorials i've seen of distutils or setuptools seem geared toward distributing so-called "python packages"; i.e., collections of closely related python modules, intended imported unit else.

i have different: large command line script. script lives in python project structure looks similar this:

git_repo/     .gitignore     readme.rst     src/         myscript.py         sub_module1.py         sub_module2.py         sub_module3.py     test/         test_sub_module1.py         test_sub_module2.py         test_sub_module3.py 

inside of myscript.py file, first several lines this:

#!/usr/bin/env python  import sub_module1 import sub_module2 import sub_module3  # go bunch of stuff... # etc... 

the code contained in various submodules stuff couldn't imagine ever wanting re-use in project; pieces specific main application, myscript.py. in addition, material inside of each submodule.py file not closely related between 1 submodule , another. collectively, don't think particularly natural or logical group them sub-package own __init__.py file. in fact, reason have these submodule files in first place organize main script more cleanly; doing way results in top-level myscript.py file coming out to, say, 100 lines, rather piled single massive 1000 line scroll.

within git_repo/src directory, can execute script typing out @ command line, e.g.:

./myscript.py --opt1 <value_1> --opt2 <value_2> --opt3 <value_3> ... 

my question: since project command line script , not importable package, how should call setuptools setup() function in case? how select input parameters setup() in order let know should treat myscript.py executable script (meaning, example, knows chmod 755 myscript.py during installation), while making clear accompanying submodule.py files, although not scripts themselves, nevertheless required dependencies should installed adjacent myscript.py within same directory? correct form of setup function in case?

you should use setuptools entry points , pip install pkg create bin/ script you. when system-wide package installation script go /usr/bin or /usr/local/bin.

about entry points


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -