|
15 | 15 | from pex.third_party import attr
|
16 | 16 |
|
17 | 17 |
|
| 18 | +def _convert_non_pep_440_dev_versions(python_full_version): |
| 19 | + # type: (Optional[str]) -> Optional[str] |
| 20 | + |
| 21 | + # This applies the same workaround that exists in packaging as of its 24.1 release. |
| 22 | + # See: |
| 23 | + # + https://github.com/pypa/packaging/pull/802 |
| 24 | + # + https://github.com/pypa/packaging/pull/825 |
| 25 | + # |
| 26 | + # N.B.: We can't simply upgrade to packaging >= 24.1 since those changes unconditionally access |
| 27 | + # the `python_full_version` marker and our `AbbreviatedPlatform` can lead to marker environments |
| 28 | + # without that marker filled in. Even if we could upgrade packaging though, that would only help |
| 29 | + # Pex users on Python >= 3.8 whereas this fix applies to all Pex users. |
| 30 | + if python_full_version and python_full_version.endswith("+"): |
| 31 | + return python_full_version + "local" |
| 32 | + |
| 33 | + return python_full_version |
| 34 | + |
| 35 | + |
18 | 36 | @attr.s(frozen=True)
|
19 | 37 | class MarkerEnvironment(object):
|
20 | 38 | """A PEP-508 marker environment.
|
@@ -125,7 +143,9 @@ def from_platform(cls, platform):
|
125 | 143 | platform_release = attr.ib(default=None) # type: Optional[str]
|
126 | 144 | platform_system = attr.ib(default=None) # type: Optional[str]
|
127 | 145 | platform_version = attr.ib(default=None) # type: Optional[str]
|
128 |
| - python_full_version = attr.ib(default=None) # type: Optional[str] |
| 146 | + python_full_version = attr.ib( |
| 147 | + default=None, converter=_convert_non_pep_440_dev_versions |
| 148 | + ) # type: Optional[str] |
129 | 149 | python_version = attr.ib(default=None) # type: Optional[str]
|
130 | 150 | sys_platform = attr.ib(default=None) # type: Optional[str]
|
131 | 151 |
|
|
0 commit comments