Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion to pick up version from the git tag #404

Merged
merged 1 commit into from Oct 30, 2020

Conversation

Eothred
Copy link
Contributor

@Eothred Eothred commented Sep 11, 2020

Rather than hard-coding the version number in setup.py, you may follow this approach.

Benefits:

  • You ensure that the git tag is accurate
  • version is defined only in one place (the git tag itself).
  • You get remi.__version__ that tells you exact version (including commit hash), useful when users report bugs

Drawbacks:

  • version is not found in the sources anymore, which may be of interest for historical reasons in the long run
  • import remi is a bit slower now it looks like. This is to get remi.__version__ dynamically, that part could be excluded.

Below you see how it looks at runtime. The dev66 part means "66 commits ahead of the tag 2020.3.11". f276307 is the short hash of the exact commit.

% python
Python 3.8.5 (default, Sep  5 2020, 10:50:12) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import remi
>>> remi.__version__
'2020.3.11.dev69+gf276307'

add remi.__version__ at runtime
@Eothred
Copy link
Contributor Author

Eothred commented Sep 11, 2020

So there are then two separate parts to this suggestion, you might like none of them, one of them or both:

  • use scm to define version number
  • have the version number easily accessible at runtime

@dddomodossola
Copy link
Collaborator

This is great, I will test it soon ;-)

@dddomodossola
Copy link
Collaborator

@Eothred can you please teach me on how to add scm version number?

@Eothred
Copy link
Contributor Author

Eothred commented Oct 27, 2020

scm version = git tag (scm just a general abbreviation for source-control management, could be other systems than git).

So with this proposal (which depending on how you prefer it, you may reject), whenever you make a git tag, that becomes the new version of the python library as well.

@dddomodossola
Copy link
Collaborator

:D That's right, I confused scm with svn . I have one question. How you generated the following version number '2020.3.11.dev69+gf276307' ? Which git command you used?

@Eothred
Copy link
Contributor Author

Eothred commented Nov 7, 2020

Sorry for the late reply.

The command to generate this is git describe.

Apologies for messing up the builds without the git repository. In that case it might be that this MR is causing more harm than good. Your solution is neat though

@dddomodossola
Copy link
Collaborator

@Eothred No problem ;-). However this is a good improvement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants