Python #
Embedding Version Information in Packages #
For a real example see tinyssh-keyconvert@0.3.1…0.3.2.
Version information should be single-sourced if you ask me. I’ve described my thoughts in a blog post, which culminated in my ansemjo/version.sh script.
To solve this problem for Python packages:
- Use
version.sh
script- Modify the release seperator to
-dev
- Use only
version
output, notdescribe
, to conform to PEP440
- Modify the release seperator to
- Read version from script with a
subprocess
command during packaging - Write that version into a simple file that exports
__version__
in your package - In your script try to import said
__version__
in atry-except
-clause and fallback - Now you can use the same
version
in the script .. yay!