Skip to content

Commit c4bfd8d

Browse files
committed
Conditionally disable the pytest distribution package test
When running tests under Python 3.12 with setuptools_scm==3.4.1, we run into a problem where a call to setuptools.setup() tries to load a newer version of setuptools_scm, and that conflicts with the older version that is already in sys.modules. I haven't fully figured out the details, but the gist is that setuptools attempts to read and install the entry point specifications from the newer version of setuptools_scm while using the older version's code, and there is one particular entry point whose value refers to the setuptools_scm._integration module which doesn't exist in the older version's code. This winds up breaking every test that runs after the older version of setuptools_scm gets loaded. We have various options for fixing this, but I don't want to hold up the release any longer while figuring out what the best way to do it is. (I'm guessing that the best approach is just to use virtual environments for distribution package tests, but I want to explore the options.) So I'm disabling the distribution package test which triggers this error when using Python>=3.12 and setuptools_scm<6. We can implement a proper fix later.
1 parent 43d9538 commit c4bfd8d

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

tests/distribution/test_distribution_packages.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"""
2222

2323
import pytest
24+
import sys
2425

2526
from typing import Iterator, List
2627

@@ -47,11 +48,36 @@ def _xfail(*args):
4748
return pytest.param(*args, marks=pytest.mark.xfail)
4849

4950

51+
def _setuptools_scm_version_conflict() -> bool:
52+
"""
53+
Check whether the conditions exist to trigger the ``setuptools_scm`` version
54+
conflict. If these conditions exist, certain tests should be skipped.
55+
See `issue 145 <https://github.com/diazona/setuptools-pyproject-migration/issues/145>`_.
56+
"""
57+
58+
if sys.version_info < (3, 12):
59+
return False
60+
from test_support import importlib_metadata
61+
from packaging.version import Version
62+
63+
try:
64+
setuptools_scm_version = Version(importlib_metadata.version("setuptools_scm"))
65+
except importlib_metadata.PackageNotFoundError:
66+
return False
67+
return setuptools_scm_version < Version("6")
68+
69+
5070
distributions: List = [
5171
# e.g.
5272
# GitHubDistribution(url, commit-ish)
5373
# PyPiDistribution(name, version)
54-
_xfail(PyPiDistribution("pytest", "7.3.0")),
74+
pytest.param(
75+
PyPiDistribution("pytest", "7.3.0"),
76+
marks=[
77+
pytest.mark.xfail,
78+
pytest.mark.skipif(_setuptools_scm_version_conflict(), reason="Issue #145"),
79+
],
80+
),
5581
_xfail(PyPiDistribution("pytest-localserver", "0.8.0")),
5682
PyPiDistribution("aioax25", "0.0.11.post0", make_importable=True),
5783
]

0 commit comments

Comments
 (0)