-
Notifications
You must be signed in to change notification settings - Fork 39
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
Include rc/post/dev in version. #260
Conversation
@decathorpe Would you review these changes? Overall: rather than discarding a/b/rc/dev/post information provided in Python versions, those will be preserved and transformed into something that rpm understands. Because the version string may be modified for the rpm Version:, but used literally in filesystem paths, the original value needs to be stored in a define/global value in the spec file, the same way that package names are handled. Most values of %{version} are replaced with %{pypi_version}, similar to the use of %{pypi_name} In filters.py, I've introduced two new filters. One will convert a/b/rc/dev to a tilde suffix which should be supported on RHEL 6 and 7 (I'll test that asap), and the other will convert a/b/rc/dev to a tilde suffix and also convert post to a caret suffix. If the original version doesn't need any transformation, the filter returns "%{pypi_version}", which produces a spec file that needs minimal modification for future releases. The exception is for the changelog, where the pypi_version macro can't be used, so the filters accept a flag indicating whether or not the macro or the literal version is returned. Also in filters, macroed_url is updated to recognize the use of pypi_version rather than version. package_getters.py is updated to preserve the version suffix which was previously discarded. The majority of this PR is changes to the templates and the tests. |
CentOS 7 can install packages with ~ version, and:
|
This is a bit above my paygrade ... The thing that*s weird though is that this PR has six commits of which 5 have the same message, making it hard to review, since you can't tell which commit is supposed to do what. Breaking the "flesh" of this change into multiple commits would also make it easier to review :) |
4ecff4f
to
eeaad79
Compare
I'd intended to squash it all to one since the vast majority of this change is just the same update to many templates and the corresponding test spec files. I've reorganized the commits. |
Thanks! I'll leave some comments inline. |
return default | ||
rpm_version, rpm_suffix = re_match.groups() | ||
if rpm_suffix.startswith("dev"): | ||
return '{}~~{}'.format(rpm_version, rpm_suffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we actually should support -dev versions? Doing so makes this non-standard double-tilde necessary, and it's at least not covered by the Fedora packaging guidelines at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double tilde is what the Python dist RPM dependency generator does for dev.
else: | ||
default = version | ||
re_match = re.compile( | ||
r"(\d+\.?\d*\.?\d*\.?\d*)\.?((?:a|b|rc|post|dev)\d*)").search( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this regex contain post
as choice, but the one above does not?
And should we actually support post
and dev
versions in pyp2rpm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added documentation to the filter functions. rpm 4.10 - 4.14 support pre-release suffixes. 4.15 added support for a post-release suffix.
Last question: When running pyp2rpm now, will it choose the latest version regardless of alpha / beta / rc status now? At least I think by default it should use the latest "stable" release, and using a newer prerelease should be optional (either by specifying the version manually or by setting a |
Lines 127 to 130 in 24002cc
|
@@ -71,11 +74,49 @@ def macroed_url(url): | |||
return url | |||
|
|||
|
|||
def rpm_version_410(version, use_macro=True): | |||
if use_macro: | |||
default = '%{pypi_version}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it is defined in the spec file.
Oh. So I was thinking. What if we have a Usage:
I would definitively use it in some of the packages. There is |
From a maintenance point of view: I lean toward consistency with existing behavior. pyp2rpm already uses %{pypi_name} for the unmodified name, and converts to an rpm-semantics name where those are required. If we do the inverse here, storing the converted version in the Version field and converting to the pypi semantics for the filesystem paths, we should have a good reason for the inconsistent behavior. From an implementation point of view: Python is a bit permissive with version parsing, and I worry that someday we'd see packages where attempting to convert back to the original version didn't work (as it would not have in issue 259, which prompted this change).
|
I see. I'd still like to have macro I can use that would strip tildes and carets from version :( |
The Rust macros have some version of this, at least for stripping tilde to convert back to semver ( |
Yes but that replaces the tilde with dash by default and the only way to wwork around it is to provide empty string as the first argument to that macro. Which is not readable: |
rather than "version". Where the RPM version is needed, use the new macros to convert the original version string to the RPM equivalent.
https://src.fedoraproject.org/rpms/python-rpm-macros/pull-request/101 |
I think I already reviewed this once ... unless you made some drastic changes, and it works ... |
No description provided.