Python package with multiple "packages"?
Question:
Assume I have a project which looks like
uilities.py
api_1.py
api_2.py
api_3.py
foo.py
bar.py
baz.py
The utilites and api calls does nothing by their own, but they form 90% of the contents of foo.py, bar.py and baz.py.
-
The contents of foo.py, bar.py and baz.py. are very bare bones, including the commandline interface they are maybe 200 lines each.
-
The utility.py and api_?.py does little to nothing on their own.
E.g when I call
foo -a --other-arg
Instead of doing, which is what I tried
long_main_package_name foo -a --other-arg
How should i structure my project so that I can call foo.py, bar.py and baz.py directly after installing the package?
Answers:
You can declare them as console scripts in the setup for building the package for distribution.
More details here: https://setuptools.pypa.io/en/latest/userguide/entry_point.html
Assume I have a project which looks like
uilities.py
api_1.py
api_2.py
api_3.py
foo.py
bar.py
baz.py
The utilites and api calls does nothing by their own, but they form 90% of the contents of foo.py, bar.py and baz.py.
-
The contents of foo.py, bar.py and baz.py. are very bare bones, including the commandline interface they are maybe 200 lines each.
-
The utility.py and api_?.py does little to nothing on their own.
E.g when I call
foo -a --other-arg
Instead of doing, which is what I tried
long_main_package_name foo -a --other-arg
How should i structure my project so that I can call foo.py, bar.py and baz.py directly after installing the package?
You can declare them as console scripts in the setup for building the package for distribution.
More details here: https://setuptools.pypa.io/en/latest/userguide/entry_point.html