Python #
Embedding Version Information in Packages #
For a real example see [tinyssh-keyconvert@0.3.1...0.3.2](https://github.com/ansemjo/tinyssh-keyconvert/compare/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.shscript- Modify the release seperator to
-dev - Use only
versionoutput, notdescribe, to conform to PEP440
- Modify the release seperator to
- Read version from script with a
subprocesscommand 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
versionin the script .. yay!