Suppose I have a python package called mypackage, which has a series of scripts. Once mypackage is in the site-packages dir, the user can refer to various Python files within mypackage as mypackage.submodule1, mypackage.submodule2 from Python, as usual. However, some of these are scripts that are meant to be called from the command line. In submodule1 for example, I have:
== mypackage/submodule1.py ==
if __name__ == '__main__':
main()
def main():
# parse command line options here, do stuff
How can I properly distribute/package mypackage so that the user can cleanly use these submodules as command line scripts once "mypackage" is in their path? I would have thought you can do:
python mypackage.submodule1.py arg1 arg2 ...
but this syntax is invalid. In other words, how can the user refer to submodules of my package as scripts rather than importing them from Py, without requiring the actual "mypackage" dir to be in their PYTHONPATH? (Only the toplevel directory, e.g. site-packages, which contains "mypackage" should be in their PYTHONPATH.)
Thanks.