Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have my python file show its mercurial tag or revision as the module version?

I'd like to add a --version command line option to my python application that will show the right version depending on the tagged status of the command:

If the file comes from a version whose short hex ID was abcdef01 that was tagged TAG, --version should show this:

MyApp Version TAG (abcdef01)

If the file comes from the tip, --version should show this:

MyApp (tip)

If the file comes from an arbitrary, untagged revision abcdef02, --version should show this:

MyApp (development, abcdef02)

Is this possible? If so, how?

like image 288
Chris R Avatar asked Feb 02 '26 04:02

Chris R


1 Answers

Once you activate the keyword extension, you can have it in a variable which can be carved up for the hash.

like image 143
Ignacio Vazquez-Abrams Avatar answered Feb 03 '26 16:02

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!