Skip to content

Commit

Permalink
chore(packaging): support version parsing in packaging v22 [backport D…
Browse files Browse the repository at this point in the history
…ataDog#4752 to 1.6] (DataDog#4765)

## Description

Backport DataDog#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 <brett.langdon@datadoghq.com>
  • Loading branch information
mabdinur and brettlangdon committed Dec 12, 2022
1 parent 1ae84a1 commit c5c5bec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion ddtrace/internal/utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def parse_version(version):

# version() will not raise an exception, if the version if malformed instead
# we will end up with a LegacyVersion
parsed = packaging.version.parse(version)

try:
parsed = packaging.version.parse(version)
except packaging.version.InvalidVersion:
# packaging>=22.0 raises an InvalidVersion instead of returning a LegacyVersion
return (0, 0, 0)

# LegacyVersion.release will always be `None`
if not parsed.release:
Expand Down
12 changes: 8 additions & 4 deletions riotfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,15 @@ def select_pys(min_version=MIN_PYTHON_VERSION, max_version=MAX_PYTHON_VERSION):
"DD_REMOTE_CONFIGURATION_ENABLED": "false",
},
venvs=[
Venv(pys="2.7"),
Venv(pys="2.7", pkgs={"packaging": ["==17.1", latest]}),
Venv(
# FIXME[bytecode-3.11]: internal depends on bytecode, which is not python 3.11 compatible.
pys=select_pys(min_version="3.5"),
pkgs={"pytest-asyncio": latest},
pys=select_pys(min_version="3.5", max_version="3.6"),
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", latest]},
),
# FIXME[bytecode-3.11]: internal depends on bytecode, which is not python 3.11 compatible.
Venv(
pys=select_pys(min_version="3.7"),
pkgs={"pytest-asyncio": latest, "packaging": ["==17.1", "==22.0", latest]},
),
],
),
Expand Down

0 comments on commit c5c5bec

Please sign in to comment.