Reputation: 22050
I have a python script that outputs the program name, version number and the author when called with command line arguments like --help or --version. Currently this information is hardcoded in the python script itself. But I use distutils for building/packaging the application so all this information is already present in the setup.py. Is it possible to let distutils write metadata like version and author name/email to the built python script so I only need to maintain this data in the setup.py file? Or is there another standard mechanism to handle stuff like that?
Upvotes: 2
Views: 205
Reputation: 6434
Have a file __version__.py
in your package's root, create it on build with setup.py and fetch version information from it for --help or --version. That's how Mercurial rolls.
Upvotes: 2
Reputation:
Do it the other way around. Add the version number, the author name and other metadata you need in the script to the script itself. Then import
or execfile()
the script in setup.py
, and use the metadata defined in the script as arguments to the setup()
function.
Upvotes: 3