setup: sanitize package version#3862
Merged
gpotter2 merged 2 commits intosecdev:masterfrom Feb 13, 2023
Merged
Conversation
Currently, when installing from a non-tagged git archive version we get an error from pkg_resources: pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'git-archive.dev95ba5b8504' This version does not comply with the PEP 440 standard. Update the parsing of git-archive %(describe) placeholder by adding multiple safeguards for computing scapy.VERSION (the first successful method is used in priority): 1) If the SCAPY_VERSION env var is defined, use it. This will allow downstream packaging to force a specific version even if they store scapy in a different repository using a different git tag scheme. 2) If the scapy/VERSION file exists, use its contents. 3) Try to parse a tag from a git archive %(describe) placeholder. If the git archive was not made on a tag, use the commit timestamp to convert it to a date YYYY.MM.DD which is PEP 440 compatible. 4) Try to use git describe to generate a tag. 5) Use the last modification date of scapy/__init__.py and generate a date YYYY.MM.DD which is PEP 440 compatible. 6) Return 0.0.0 Do not try to generate the scapy/VERSION file when importing scapy anymore but generate it by overriding the sdist command in setup.py and write it to the temp folder used for the source archive generation. Update unit tests to ensure that order of priority is enforced. Link: https://peps.python.org/pep-0440/ Link: https://bugzilla.redhat.com/show_bug.cgi?id=2162667 Signed-off-by: Robin Jarry <rjarry@redhat.com>
Codecov Report
@@ Coverage Diff @@
## master #3862 +/- ##
==========================================
- Coverage 51.93% 50.43% -1.51%
==========================================
Files 190 227 +37
Lines 43195 52757 +9562
==========================================
+ Hits 22435 26610 +4175
- Misses 20760 26147 +5387
|
Contributor
Author
|
Hey guys, gentle ping to get progress. @guedou do you have some remarks on these changes? |
Member
|
What is the command that triggers this issue? I could not reproduce it with |
Member
|
If you clone scapy with |
Member
|
So all unit tests are currently failing because of this 😆 |
Contributor
Author
|
Hehe thanks! |
muttiopenbts
pushed a commit
to muttiopenbts/scapy
that referenced
this pull request
Feb 21, 2023
* setup: sanitize package version Currently, when installing from a non-tagged git archive version we get an error from pkg_resources: pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'git-archive.dev95ba5b8504' This version does not comply with the PEP 440 standard. Update the parsing of git-archive %(describe) placeholder by adding multiple safeguards for computing scapy.VERSION (the first successful method is used in priority): 1) If the SCAPY_VERSION env var is defined, use it. This will allow downstream packaging to force a specific version even if they store scapy in a different repository using a different git tag scheme. 2) If the scapy/VERSION file exists, use its contents. 3) Try to parse a tag from a git archive %(describe) placeholder. If the git archive was not made on a tag, use the commit timestamp to convert it to a date YYYY.MM.DD which is PEP 440 compatible. 4) Try to use git describe to generate a tag. 5) Use the last modification date of scapy/__init__.py and generate a date YYYY.MM.DD which is PEP 440 compatible. 6) Return 0.0.0 Do not try to generate the scapy/VERSION file when importing scapy anymore but generate it by overriding the sdist command in setup.py and write it to the temp folder used for the source archive generation. Update unit tests to ensure that order of priority is enforced. Link: https://peps.python.org/pep-0440/ Link: https://bugzilla.redhat.com/show_bug.cgi?id=2162667 Signed-off-by: Robin Jarry <rjarry@redhat.com> * Reject invalid git tags --------- Signed-off-by: Robin Jarry <rjarry@redhat.com> Co-authored-by: gpotter2 <10530980+gpotter2@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, when installing from a non-tagged git archive version we get an error from
pkg_resources:This version does not comply with the PEP 440 standard.
Update the parsing of git-archive
%(describe)placeholder by adding multiple safeguards for computingscapy.VERSION(the first successful method is used in priority):If the
SCAPY_VERSIONenv var is defined, use it. This will allow downstream packaging distros to force a specific version even if they store scapy in a different repository using a different git tag scheme.If the
scapy/VERSIONfile exists, use its contents.Try to parse a tag from a git archive
%(describe)placeholder. If the git archive was not made on a tag, use the commit timestamp to convert it to a dateYYYY.MM.DDwhich is PEP 440 compatible.Try to parse the version from
git describe.Use the last modification of
scapy/__init__.pyand generate a dateYYYY.MM.DDwhich is PEP 440 compatible.Return
0.0.0Do not try to generate the
scapy/VERSIONfile when importingscapyanymore but generate it by overriding thesdistcommand insetup.pyand write it to the temp folder used for the source archive generation.Update unit tests to ensure that order of priority is enforced.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2162667