Skip to content

Commit c5c5bec

Browse files
chore(packaging): support version parsing in packaging v22 [backport #4752 to 1.6] (#4765)
## Description Backport #4752 ## Reviewer Checklist - [ ] Title is accurate. - [ ] Description motivates each change. - [ ] No unnecessary changes were introduced in this PR. - [ ] Avoid breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Release note has been added and follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines), or else `changelog/no-changelog` label added. - [ ] All relevant GitHub issues are correctly linked. - [ ] Backports are identified and tagged with Mergifyio. Co-authored-by: Brett Langdon <[email protected]>
1 parent 1ae84a1 commit c5c5bec

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

ddtrace/internal/utils/version.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def parse_version(version):
2727

2828
# version() will not raise an exception, if the version if malformed instead
2929
# we will end up with a LegacyVersion
30-
parsed = packaging.version.parse(version)
30+
31+
try:
32+
parsed = packaging.version.parse(version)
33+
except packaging.version.InvalidVersion:
34+
# packaging>=22.0 raises an InvalidVersion instead of returning a LegacyVersion
35+
return (0, 0, 0)
3136

3237
# LegacyVersion.release will always be `None`
3338
if not parsed.release:

riotfile.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,15 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
324324
"DD_REMOTE_CONFIGURATION_ENABLED": "false",
325325
},
326326
venvs=[
327-
Venv(pys="2.7"),
327+
Venv(pys="2.7", pkgs={"packaging": ["==17.1", latest]}),
328328
Venv(
329-
# FIXME[bytecode-3.11]: internal depends on bytecode, which is not python 3.11 compatible.
330-
pys=select_pys(min_version="3.5"),
331-
pkgs={"pytest-asyncio": latest},
329+
pys=select_pys(min_version="3.5", max_version="3.6"),
330+
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", latest]},
331+
),
332+
# FIXME[bytecode-3.11]: internal depends on bytecode, which is not python 3.11 compatible.
333+
Venv(
334+
pys=select_pys(min_version="3.7"),
335+
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", "==22.0", latest]},
332336
),
333337
],
334338
),

0 commit comments

Comments
 (0)