rorybyrne / git-plan

Git Plan - a better workflow for git
MIT License
181 stars 5 forks source link

Version number generated from git tags and printed using --version #38

Closed Stedders closed 3 years ago

Stedders commented 3 years ago

Version is derived using the version-query library.

Printing using click.echo to start the process of migrating to click.

rorybyrne commented 3 years ago

Can we keep the click migration in a separate PR?

I'm pretty sure we would need to ditch the dependency injection in order to use click, so I don't want to commit to migrating yet.

Stedders commented 3 years ago

Ok, I think I have a working solution but can you advise if you are happy with the methodology

  1. Version is snapped at build/install time in the makefile
  2. Version is extracted from setup.py using PEP-440 methodology
  3. Version is saved with the installation and works outside of git

Benefits are that the version only needs to be specified using tags, no need to add to setup.py, and if the source is modified before installation the version reflects it.

The only change is that the tagging methodology has to follow PEP-440 (so v0.1.0-alpha is not valid it would need to be 0.1.0a).

Stedders commented 3 years ago

Version is now just a text string read from the py file. If you would like it saved as a text file I will need to do some Makefile shenanigans to install it.

rorybyrne commented 3 years ago

Thanks for the quick update.

It seems straightforward to make it a text file, no? I made the change here on a new branch - am I missing something?

The only reason I think it matters is that a version string like 0.1.0a1.dev10+g98667e9.d20210314 is not valid python, so we shouldn't be putting it into a .py.

Happy to merge this if we can make it a text file without too much hassle.

Stedders commented 3 years ago

Happy to look at the change, agree that it shouldn't be in the python file as raw text.

The issue is that Makefile install does not copy non-python files, I will look at how I can add it to the payload.

rorybyrne commented 3 years ago

I just ran make install on my branch, and it looks like gp --version works.

Perhaps when we use pip to install, it won't copy across a non-python file?

image

Stedders commented 3 years ago

Are you sure that is not the local git install?

I see the same behaviour in the repo but incorrect in a different shell...

/media/Dev/projects/git-plan$ git plan --version
0.1.0a1.dev2+g98667e9.d20210314
~/code/untitled$ git plan --version
dev
Stedders commented 3 years ago

...and yes, the problem is pip install -e . not copying it.

I think there is a simple fix in setup.py, just looking at it.

rorybyrne commented 3 years ago

Yes, you're right. It was finding the repo file.

Stedders commented 3 years ago

I think that'll do it. Added to sertup.py.

rorybyrne commented 3 years ago

Doesn't work for me. It looks like the _version file wasn't copied across to the .local/share/git-plan/venv/.../git_plan/ directory. image

Stedders commented 3 years ago

Weird, it was working for me and now it isn't....I blame myself. :smile:

Will look again.

rorybyrne commented 3 years ago

Haha no worries. Once it's working I'll get this merged!

Stedders commented 3 years ago

Is now good, I was trying a couple of methods to include it.

Files to include are added to the MANIFEST.in file, they don't need to be in setup.py.

Stedders commented 3 years ago

Crosses fingers...