From 911155185ae4f578c59aa6dd566179cb2e37f0a0 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Sat, 22 Jul 2023 22:54:53 -0500 Subject: [PATCH] comments and older version of setuptools compatible with test --- setup.py | 3 +++ tools/read-version | 2 +- tools/test_tools.py | 11 +++++++++-- tox.ini | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 21de1b42771..c5c441c371a 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,9 @@ from setuptools.command.egg_info import egg_info from setuptools.command.install import install +# Python-path here is a little unpredictable as setup.py could be run +# from a directory other than the root of the repo, so ensure we can find +# our utils sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))) # isort: off from setup_utils import ( # noqa: E402 diff --git a/tools/read-version b/tools/read-version index 184b8aa813b..87c7ec76465 100755 --- a/tools/read-version +++ b/tools/read-version @@ -145,4 +145,4 @@ if __name__ == "__main__": arg_use_tags = "--tags" in sys.argv or bool(os.environ.get("CI_RV_TAGS")) arg_output_json = "--json" in sys.argv output = main(arg_use_tags, arg_output_json) - sys.stdout.write(output + "\n") + print(output) diff --git a/tools/test_tools.py b/tools/test_tools.py index 03d963fcd07..81a104981c4 100644 --- a/tools/test_tools.py +++ b/tools/test_tools.py @@ -8,7 +8,14 @@ from setup_utils import version_to_pep440 -validate_version = setuptools.dist.Distribution._validate_version # type: ignore # noqa: E501 +try: + validate_version = setuptools.dist.Distribution._validate_version + setuptools.sic # pylint: disable=no-member,pointless-statement +except AttributeError: + pytest.skip( + "Unable to import necessary setuptools utilities. " + "Version is likely too old." + ) # Since read-version has a '-' and no .py extension, we have to do this # to import it @@ -29,7 +36,7 @@ def assert_valid_version(version): response = validate_version(version) - if isinstance(response, setuptools.sic): # noqa: E1101 + if isinstance(response, setuptools.sic): # pylint: disable=no-member pytest.fail(f"{version} is not PEP 440 compliant") diff --git a/tox.ini b/tox.ini index 7ad087a11a3..6e7b08a65c3 100644 --- a/tox.ini +++ b/tox.ini @@ -195,6 +195,7 @@ deps = pytest==3.3.2 pytest-cov==2.5.1 pytest-mock==1.7.1 + setuptools==44.0.0 # Needed by pytest and default causes failures attrs==17.4.0 responses==0.5.1