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
Add option to package build to disable normalization of version identifier #308
Comments
I also noticed that, if I set the version number as, say, 1.2.3-rc1, setuptools normalizes it to 1.2.3rc1. This created several problems for me when generating debian packages. Allowing such kinds of normalization do be disabled would be a major improvement. |
Would also like to be able to disable normalization, 1.2.3-rc1 being normalized to 1.2.3rc1 is causing problems for packaging for me as well. |
@dstufft, do you have any opinion on this? IIRC, it was your contribution that added the normalization. What would be the ramifications of allowing bypassing of this normalization? |
@jaraco I think as long as you still validate that it is a PEP 440 version (or warn if not.. I don't think we have it set to hard fail), not doing the normalization shouldn't be a big deal. I think my only reason to normalize was just to get everyone using the normal forms as the default since that makes things a bit saner I think. However allowing a flag to bypass normalization should not have any negative affect. |
Hi there, I was wondering if there was a status update or further discussion on this issue. I've just run into this when our CI pipeline built a new package (which appends a short git has to the version string) was changed to a different hash.
It would seem to my quick analysis that there is an overly greedy regex munging version strings... |
Not nice, but a workaround that works for me: add this to your
|
Just ran into this myself. I've already disabled the PEP 440 warnings and now I have to work around this also :( We're packaging pre-releases following the semver.org standard, entirely for internal use only. I can maybe understand PyPI rejecting "internal only" versions at registration/upload time, but rejecting it outside of a public arena seems a little heavy-handed.
I am using this monkeypatch to disable the normalization:
|
I threw together a quick proof of concept for adding a That branch can be found at https://github.com/pypa/setuptools/compare/dont-normalize, it's only two lines of code plus re-indenting a block of code to be guarded by an if statement. I don't have time right now to develop it further, it would presumably require some tests and someone to shepherd it through the contribution process, but if someone does have the time, that code there is working. |
Thanks, Donald! |
@dstufft do you need a hand to make this a bona fide PR ? |
I doubt I'm going to have the time to finish up the work that's needed to make that proof of concept into a real PR. Feel free to take it and run with it. |
@dstufft code has changed a little since but this patch (even updated for the latest code) does not seem to help correctly: for instance I cannot create a valid semver version such as |
Will you support this feature in the next release? Any plans if next release don't support the feature? Thank you. |
@an-sush if you feel this is "unfair", would you consider submitting a patch then to help right this unfair wrong? |
I created https://github.com/ccrisan/setup-no-ver-normalize to "fix" this issue in my projects. |
@ccrisan that's simple and clean. Monkey patching really allows awesome things |
Is there any update on this issue? I would like to use -alpha prefixes in my versioning as suggested by semver standard. @ccrisan your library works for the most part but converts - to _ in the wheel file. |
I took a look at this, and while it's a good proof of concept (thanks Donald), I think I'd prefer an implementation that avoided a boolean parameter alongside the version parameter, but instead have some API where the version specified carries with it the fact that it shouldn't be normalized, either by way of wrapping it in an alternate class (such as ccrisan's On the other hand, I'd also like something that if it's officially supported, would also work with declarative config. I'm considering this approach:
While I sort-of like this approach, it also causes the value to be passed in-band (in the same string as the intended value), which I dislike. I'm also considering:
Thoughts? |
How about providing an option to pass an implementation for the normalize function when calling setup, if parameter is not passed then you use the default implementation, if passed as None then you return the version as it is. You could also pass a custom implementation if you like. |
@KishanKishore you wrote:
can you elaborate and be more explicit and also include an example? |
I don't think that Honestly, all of the options seem to just conceptually be a boolean argument, just with different ways of passing it, EXCEPT for the ability to pass your own normalization function. |
In #2026, I've drafted the second approach for consideration. Test release available here. I'm leaning strongly toward this approach as it's minimally invasive and allows the special-consideration to be indicated through the same mechanism as Please give it a try. |
This builds upon pypa#308 and https://github.com/pypa/setuptools/pull/2026/files to extend support for sic versions (bypassing normalization) into pkg_resources. I found this while trying to support versions such as "1.2.3.alpha". While these worked for some setup.py commands, most continued to normalize the version (egg_info, bdist_wheel for example). Both of those use safe_version in pkg_resources, so figured extending support for sic there made the most sense.
I tried this, but I am getting the following error:
|
@oxr463 Use the newer monkey patch mentioned in a subsequent comment:
It worked for me with the latest setuptools version (50.3.2). I did not verify how far back this works in the setuptools versions. |
As an update to my previous comment, and for people that run additional tests with well-defined minimum versions of dependent packages, here is an approach that works for versions of setuptools at least back to 20.2.2:
|
Fix the following version normalization warning: " /usr/lib/python3/dist-packages/setuptools/dist.py:530: UserWarning: Normalizing '2023.01' to '2023.1' " Using suggestion from Richard Jones: pypa/setuptools#308 (comment) Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Fix the following version normalization warning: " /usr/lib/python3/dist-packages/setuptools/dist.py:530: UserWarning: Normalizing '2023.01' to '2023.1' " Using suggestion from Richard Jones: pypa/setuptools#308 (comment) Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Originally reported by: mklein0 (Bitbucket: mklein0, GitHub: mklein0)
Could an option be added to package builds to disable the use of normalized version identifiers in the final package file name?
Under previous versions of setup tools a version identifier of
20140510.003458
would generate a package name of:After setuptools 8:
My primary concern is for older installation tool/devpy versions, the package version matching will fail if I start using the new normalized package names. And I do not want to have to test it.
Aesthetics is another aspect as in this case, the version identifier is actually an encoding of an ISO8601 timestamp.:
This request is derived from issue #302
The text was updated successfully, but these errors were encountered: