nedbat / scriv

Changelog management tool
https://scriv.readthedocs.io
Apache License 2.0
256 stars 28 forks source link

Preceding v character from PEP 0440 #89

Closed ghassanmas closed 1 year ago

ghassanmas commented 1 year ago

The util extract_version function is not ignoring a preceding 'v' when exists

https://github.com/nedbat/scriv/blob/d86dc040390e5cc136c5260ead35eae2d5f8ee69/src/scriv/util.py#L53-L72

nedbat commented 1 year ago

Can you give me more details about a specific failure case? PEP 440 says to ignore the leading "v" when comparing version numbers, but I would think anyone using scriv would either have a "v" everywhere, or have it nowhere. How is Tutor using versions numbers, and what problem is scriv causing?

ghassanmas commented 1 year ago

The probelm comes when scriv not detecting that a version arleady exits in the chaneloge entries, the way to reproduce is

Regarding PEP 440, if I understood correctly for that PEP v.1.2.3 == 1.2.3, and then as I understood when normalizing a version it should be stripped.

When I used the referred package from the same PEP 440 it sripped the v

>>> from packaging import version
>>> version.parse('v1.2.3')
<Version('1.2.3')>
>>> version.parse('1.2.3')
<Version('1.2.3')>
nedbat commented 1 year ago

Why not put the "v" character into the __version__ string? Wouldn't it compare correctly then?

ghassanmas commented 1 year ago

CC: @regisb

regisb commented 1 year ago

In the context of Tutor: the __version__ string is used sometimes with and without a preceding "v". For instance, the Changelog titles include "v". But the releases that are pushed to pypi do not include "v". And in many places of the tutor code base, we make use of the Tutor version without the preceding "v".

So we can't really include the preceding "v" in tutor.about.__version__. We can however modify the scriv configuration to include the prefix in the {{ version }}. We would have to concatenate a literal with a string -- is this possible?

Alternatives include:

Sidenote: while writing this issue, I realized that the {{ version }} that is included in a GitHub release template is not the same as the scriv version, but it is sampled from the changelog title -- so it does include the "v" prefix. Is there a reason why the scriv github-release command is not fetching the version from the scriv configuration file?

nedbat commented 1 year ago

This is now released as part of scriv 1.3.1.

Is there a reason why the scriv github-release command is not fetching the version from the scriv configuration file?

Yes, so that it can be used even on projects that don't use scriv to create their changelog (like coverage.py).

regisb commented 1 year ago

Awesome, thanks!