Skip to content

Commit

Permalink
Add fallback for old packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Sep 11, 2023
1 parent c2608c5 commit dca98f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ testing-integration =
jaraco.envs>=2.2
build[virtualenv]>=1.0.3
filelock>=3.4.0
packaging
packaging>=23.1 # TODO: update once packaging 23.2 is available

docs =
# upstream
Expand Down
9 changes: 9 additions & 0 deletions setuptools/tests/_packaging_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from packaging import __version__ as packaging_version

if tuple(packaging_version.split(".")) >= ("23", "2"):
from packaging.metadata import Metadata
else:
# Just pretend it exists while waiting for release...
from unittest.mock import MagicMock

Metadata = MagicMock()
4 changes: 3 additions & 1 deletion setuptools/tests/config/test_apply_pyprojecttoml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import pytest
from ini2toml.api import Translator
from packaging.metadata import Metadata

# TODO: replace with `from packaging.metadata import Metadata` in future versions
from .._packaging_compat import Metadata

import setuptools # noqa ensure monkey patch to metadata
from setuptools.dist import Distribution
Expand Down
3 changes: 2 additions & 1 deletion setuptools/tests/test_core_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import pytest

from packaging.metadata import Metadata
# TODO: replace with `from packaging.metadata import Metadata` in future versions:
from ._packaging_compat import Metadata

from setuptools import sic, _reqs
from setuptools.dist import Distribution
Expand Down

0 comments on commit dca98f8

Please sign in to comment.