Skip to content

Commit

Permalink
Conditionally disable the pytest distribution package test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
diazona committed Dec 27, 2023
1 parent 43d9538 commit c4bfd8d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/distribution/test_distribution_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"""

import pytest
import sys

from typing import Iterator, List

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


def _setuptools_scm_version_conflict() -> bool:
"""
Check whether the conditions exist to trigger the ``setuptools_scm`` version
conflict. If these conditions exist, certain tests should be skipped.
See `issue 145 <https://github.com/diazona/setuptools-pyproject-migration/issues/145>`_.
"""

if sys.version_info < (3, 12):
return False
from test_support import importlib_metadata
from packaging.version import Version

try:
setuptools_scm_version = Version(importlib_metadata.version("setuptools_scm"))
except importlib_metadata.PackageNotFoundError:
return False
return setuptools_scm_version < Version("6")


distributions: List = [
# e.g.
# GitHubDistribution(url, commit-ish)
# PyPiDistribution(name, version)
_xfail(PyPiDistribution("pytest", "7.3.0")),
pytest.param(
PyPiDistribution("pytest", "7.3.0"),
marks=[
pytest.mark.xfail,
pytest.mark.skipif(_setuptools_scm_version_conflict(), reason="Issue #145"),
],
),
_xfail(PyPiDistribution("pytest-localserver", "0.8.0")),
PyPiDistribution("aioax25", "0.0.11.post0", make_importable=True),
]
Expand Down

0 comments on commit c4bfd8d

Please sign in to comment.