Skip to content

Commit 212fad9

Browse files
chore(packaging): support version parsing in packaging v22 [backport #4752 to 1.5] (#4766)
## 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 85ccdf3 commit 212fad9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,15 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
299299
name="internal",
300300
command="pytest {cmdargs} tests/internal/",
301301
venvs=[
302-
Venv(pys="2.7"),
302+
Venv(pys="2.7", pkgs={"packaging": ["==17.1", latest]}),
303303
Venv(
304-
pys=select_pys(min_version="3.5"),
305-
pkgs={"pytest-asyncio": latest},
304+
pys=select_pys(min_version="3.5", max_version="3.6"),
305+
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", latest]},
306+
),
307+
# FIXME[bytecode-3.11]: internal depends on bytecode, which is not python 3.11 compatible.
308+
Venv(
309+
pys=select_pys(min_version="3.7"),
310+
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", "==22.0", latest]},
306311
),
307312
],
308313
pkgs={

0 commit comments

Comments
 (0)