Skip to content
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

fix: Sanitize Python version to be PEP 440 compliant #1605

Conversation

matthewfeickert
Copy link
Contributor

To avoid errors in modern versions of pip, ensure that the version name created for the Python bindings is sanitized to be compliant with PEP 440

c.f.:

This essentially means that the version number needs to pass pip._vendor.packaging.version.Version()

Example:

from pip._vendor.packaging.version import Version

Version("v20220128-34c8a39")  # pip._vendor.packaging.version.InvalidVersion: Invalid version: 'v20220128-34c8a39'
Version("2022.128")  # <Version('2022.128')>
Version("2022.128+a28a91c")  # <Version('2022.128+a28a91c')>
Version("6.0.0")  # <Version('6.0.0')>

To avoid errors in modern versions of pip, ensure that the version name
created for the Python bindings is sanitized to be compliant with PEP 440

c.f.:
* https://www.python.org/dev/peps/pep-0440/
* pip GitHub Issue #8368

This essentially means that the version number needs to pass
`pip._vendor.packaging.version.Version()`

Example:

```
from pip._vendor.packaging.version import Version
Version("v20220128-34c8a39")  # pip._vendor.packaging.version.InvalidVersion: Invalid version: 'v20220128-34c8a39'
Version("2022.128")  # <Version('2022.128')>
Version("2022.128+a28a91c")  # <Version('2022.128+a28a91c')>
Version("6.0.0")  # <Version('6.0.0')>
```
As discovered in XRootD Issue xrootd#1604 there are instances where if a Git tag
is created, then the current xrootd.egg-info that is generated in the top
level of the repository by the current packaging/wheel/publish.sh workflow
will pollute the PYTHONPATH (which includes the current working directory by
default --- this is one of the reasons src directory structures are currently
recommended by the PyPA) causing problems with trying to install the built sdist
from the top level of the repo with `python3 -m pip install dist/xrootd*.tar.gz`.

Ideally the publish.sh workflow should be refactored to make this not a problem,
but for the time being just use the easy workaround of changing paths so that the
xrootd.egg-info directory is not on PYTHONPATH and install the sdist normally.
@matthewfeickert
Copy link
Contributor Author

matthewfeickert commented Jan 28, 2022

@simonmichal this is ready for review. I'm happy to answer any questions on it, but I tried to do some brain dumps into the relevant commit messages to guide anyone in the future who might need to debug anything related to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants