Reputation: 10704
I have a directory I want to distribute to colleagues which has the following files:
__init__.py
common.py
file_downloader.py
builder.py
repo_setup.py
Right now, the file i have set up to be the main function is repo_setup.py as it has the def main():
i am looking for.
I normally would just run that file and everything works. It isnt quite intuitive to run that file though, and was curious what the standard is for the primary file to kick off everything
I was thinking to just create a main.py which would kick off everything and plausibly have a readme as well.
Is there a Python standard for developing a project with multiple files and distributing it though email or thumb drive?
I felt that leveraging setup.py isnt needed since it doesn't require any other packages to run. Maybe this is actually the best course of action though. My first look didn't see any run property which accepted a executable list to run in order after setup complex. Maybe executing setup.py would run a list of python files in order after all packages are installed?
Upvotes: 4
Views: 316
Reputation: 19174
You could do part of what is done for IDLE with idlelib. Call the directory project
. Add project.__main__
with
from project.repo_setup import main
main()
Put (unzip) the project
directory (with its .py files) in .../lib/site-packages
. This puts project
on sys.path
and makes it both importable and runnable (as a main module). Run from a command line with python -m project
. (Or python3 depending of version and OS.)
Upvotes: 1