tests: Skip tests that break on newer setuptools
These are all broken on setuptools >= v80.0.0 due to the removal of easy_install there. This solution is at most a stop-gap and we have a bigger issue to resolve here - namely figuring out how to support these once distros start packaging newer setuptools. However, it at least unblocks the gate for us. We also need to fix another issue, ensuring that we normalize constraints as we do package names. This fixes issue with glance-store, which is listed as 'glance_store' since [1]. [1] https://review.opendev.org/c/openstack/requirements/+/942508/ Change-Id: I599cb05706753c89f0ba74ee17446e62abd79b5d Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
@@ -131,6 +131,14 @@ class BaseTestCase(testtools.TestCase, testresources.ResourcedTestCase):
|
||||
def run_pbr(self, *args, **kwargs):
|
||||
return self._run_cmd('pbr', args, **kwargs)
|
||||
|
||||
def get_setuptools_version(self):
|
||||
# we rely on this to determine whether to skip tests, so we can't
|
||||
stdout, _, _ = self._run_cmd(
|
||||
sys.executable,
|
||||
('-c', 'import setuptools; print(setuptools.__version__)'),
|
||||
allow_fail=False)
|
||||
return tuple(int(x) for x in stdout.strip().split('.')[:3])
|
||||
|
||||
def run_setup(self, *args, **kwargs):
|
||||
return self._run_cmd(sys.executable, ('setup.py',) + args, **kwargs)
|
||||
|
||||
|
||||
@@ -102,8 +102,7 @@ class TestCore(base.BaseTestCase):
|
||||
stdout, _, return_code = self.run_setup(
|
||||
'install_scripts', '--install-dir=%s' % self.temp_dir)
|
||||
|
||||
self.useFixture(
|
||||
fixtures.EnvironmentVariable('PYTHONPATH', '.'))
|
||||
self.useFixture(fixtures.EnvironmentVariable('PYTHONPATH', '.'))
|
||||
|
||||
self.check_script_install(stdout)
|
||||
|
||||
@@ -119,6 +118,14 @@ class TestCore(base.BaseTestCase):
|
||||
if os.name == 'nt':
|
||||
self.skipTest('Windows support is passthrough')
|
||||
|
||||
# setuptools v80.0.0 switched to using pip for the 'develop' command,
|
||||
# which means easy_install is no longer invoked
|
||||
#
|
||||
# https://github.com/pypa/setuptools/commit/98e6b4cac625c6c13b718eeccea42d00d75f2577
|
||||
# https://setuptools.pypa.io/en/stable/history.html#v80-0-0
|
||||
if self.get_setuptools_version() >= (80, 0):
|
||||
self.skipTest('setuptools is too new')
|
||||
|
||||
self.useFixture(
|
||||
fixtures.EnvironmentVariable(
|
||||
'PYTHONPATH', ".:%s" % self.temp_dir))
|
||||
|
||||
@@ -107,30 +107,36 @@ class TestIntegration(base.BaseTestCase):
|
||||
with open(tmp_constraints, 'w') as dest:
|
||||
for line in src:
|
||||
constraint = line.split('===')[0]
|
||||
constraint = pkg_resources.safe_name(constraint).lower()
|
||||
if project_name != constraint:
|
||||
dest.write(line)
|
||||
pip_cmd = PIP_CMD + ['-c', tmp_constraints]
|
||||
|
||||
venv = self.useFixture(
|
||||
test_packaging.Venv('sdist',
|
||||
modules=['pip', 'wheel', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
test_packaging.Venv(
|
||||
'sdist',
|
||||
modules=['pip', 'wheel', 'setuptools<80', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
python = venv.python
|
||||
self.useFixture(base.CapturedSubprocess(
|
||||
'sdist', [python, 'setup.py', 'sdist'], cwd=path))
|
||||
|
||||
venv = self.useFixture(
|
||||
test_packaging.Venv('tarball',
|
||||
modules=['pip', 'wheel', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
test_packaging.Venv(
|
||||
'tarball',
|
||||
modules=['pip', 'wheel', 'setuptools<80', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
python = venv.python
|
||||
filename = os.path.join(
|
||||
path, 'dist', os.listdir(os.path.join(path, 'dist'))[0])
|
||||
self.useFixture(base.CapturedSubprocess(
|
||||
'tarball', [python] + pip_cmd + [filename]))
|
||||
|
||||
venv = self.useFixture(
|
||||
test_packaging.Venv('install-git',
|
||||
modules=['pip', 'wheel', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
test_packaging.Venv(
|
||||
'install-git',
|
||||
modules=['pip', 'wheel', 'setuptools<80', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
root = venv.path
|
||||
python = venv.python
|
||||
self.useFixture(base.CapturedSubprocess(
|
||||
@@ -141,14 +147,16 @@ class TestIntegration(base.BaseTestCase):
|
||||
if 'alembic.ini' in filenames:
|
||||
found = True
|
||||
self.assertTrue(found)
|
||||
|
||||
venv = self.useFixture(
|
||||
test_packaging.Venv('install-e',
|
||||
modules=['pip', 'wheel', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
test_packaging.Venv(
|
||||
'install-editable',
|
||||
modules=['pip', 'wheel', 'setuptools<80', PBRVERSION],
|
||||
pip_cmd=PIP_CMD))
|
||||
root = venv.path
|
||||
python = venv.python
|
||||
self.useFixture(base.CapturedSubprocess(
|
||||
'install-e', [python] + pip_cmd + ['-e', path]))
|
||||
'install-editable', [python] + pip_cmd + ['-e', path]))
|
||||
|
||||
|
||||
class TestInstallWithoutPbr(base.BaseTestCase):
|
||||
@@ -206,9 +214,10 @@ class TestInstallWithoutPbr(base.BaseTestCase):
|
||||
allow_fail=False, cwd=req_pkg_dir)
|
||||
# A venv to test within
|
||||
# We install setuptools because we rely on setup.py below.
|
||||
venv = self.useFixture(test_packaging.Venv('nopbr',
|
||||
['pip', 'wheel',
|
||||
'setuptools']))
|
||||
# FIXME(stephenfin): We should not need to pin setuptools
|
||||
# https://github.com/pypa/setuptools/commit/ef4cd2960d75f2d49f40f5495347523be62d20e5
|
||||
venv = self.useFixture(
|
||||
test_packaging.Venv('nopbr', ['pip', 'wheel', 'setuptools<80']))
|
||||
python = venv.python
|
||||
# Install both packages
|
||||
self.useFixture(base.CapturedSubprocess(
|
||||
@@ -221,7 +230,7 @@ class TestInstallWithoutPbr(base.BaseTestCase):
|
||||
'nopbr', [pbr_cmd] + ['freeze'], cwd=test_pkg_dir))
|
||||
|
||||
|
||||
# Handle various comaptibility issues with pip and setuptools versions against
|
||||
# Handle various compatability issues with pip and setuptools versions against
|
||||
# python3 versions. Unfortunately python3.12 in particular isn't very backward
|
||||
# compatible with pip and setuptools.
|
||||
# TODO(clarkb) add other distros like EL9 and EL10
|
||||
|
||||
@@ -185,7 +185,7 @@ class Venv(fixtures.Fixture):
|
||||
"""
|
||||
self._reason = reason
|
||||
if modules == ():
|
||||
modules = ['pip', 'wheel', 'build', 'setuptools', PBR_ROOT]
|
||||
modules = ['pip', 'wheel', 'build', 'setuptools<80', PBR_ROOT]
|
||||
self.modules = modules
|
||||
if pip_cmd is None:
|
||||
self.pip_cmd = ['-m', 'pip', '-v', 'install']
|
||||
|
||||
@@ -134,12 +134,17 @@ function check_setuppy {
|
||||
# behaviors.
|
||||
$epvenv/bin/pip $PIPFLAGS install -f $WHEELHOUSE setuptools
|
||||
|
||||
# FIXME(stephenfin): This is broken with setuptools v80.0.0+ since that no
|
||||
# longer invokes easy_install but rather defers to pip. In CI, we only see
|
||||
# this failure on Noble or later, because Jammy's version of Python is too
|
||||
# old for setuptools v80.0.0+
|
||||
|
||||
# First check develop
|
||||
PBR_VERSION=0.0 $epvenv/bin/python setup.py develop
|
||||
cat $epvenv/bin/test_cmd
|
||||
grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
$epvenv/bin/test_cmd | grep 'Test cmd'
|
||||
PBR_VERSION=0.0 $epvenv/bin/python setup.py develop --uninstall
|
||||
# PBR_VERSION=0.0 $epvenv/bin/python setup.py develop
|
||||
# cat $epvenv/bin/test_cmd
|
||||
# grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
# $epvenv/bin/test_cmd | grep 'Test cmd'
|
||||
# PBR_VERSION=0.0 $epvenv/bin/python setup.py develop --uninstall
|
||||
|
||||
# Now check install
|
||||
PBR_VERSION=0.0 $epvenv/bin/python setup.py install
|
||||
@@ -157,20 +162,25 @@ function check_pip {
|
||||
mkvenv $epvenv
|
||||
$epvenv/bin/pip $PIPFLAGS install -f $WHEELHOUSE -e $eppbrdir
|
||||
|
||||
# FIXME(stephenfin): This is broken with setuptools v80.0.0+ since that no
|
||||
# longer invokes easy_install but rather defers to pip. In CI, we only see
|
||||
# this failure on Noble or later, because Jammy's version of Python is too
|
||||
# old for setuptools v80.0.0+
|
||||
|
||||
# First check develop
|
||||
PBR_VERSION=0.0 $epvenv/bin/pip install -e ./
|
||||
cat $epvenv/bin/test_cmd
|
||||
if [ -f ./pyproject.toml ] ; then
|
||||
# Pip dev installs with pyproject.toml build from editable wheels
|
||||
# which do not use PBR generated console scripts.
|
||||
grep 'from test_project import main' $epvenv/bin/test_cmd
|
||||
! grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
else
|
||||
# Otherwise we should get the PBR generated script
|
||||
grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
fi
|
||||
$epvenv/bin/test_cmd | grep 'Test cmd'
|
||||
PBR_VERSION=0.0 $epvenv/bin/pip uninstall -y test-project
|
||||
# PBR_VERSION=0.0 $epvenv/bin/pip install -e ./
|
||||
# cat $epvenv/bin/test_cmd
|
||||
# if [ -f ./pyproject.toml ] ; then
|
||||
# # Pip dev installs with pyproject.toml build from editable wheels
|
||||
# # which do not use PBR generated console scripts.
|
||||
# grep 'from test_project import main' $epvenv/bin/test_cmd
|
||||
# ! grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
# else
|
||||
# # Otherwise we should get the PBR generated script
|
||||
# grep 'PBR Generated' $epvenv/bin/test_cmd
|
||||
# fi
|
||||
# $epvenv/bin/test_cmd | grep 'Test cmd'
|
||||
# PBR_VERSION=0.0 $epvenv/bin/pip uninstall -y test-project
|
||||
|
||||
# Now check install
|
||||
PBR_VERSION=0.0 $epvenv/bin/pip install ./
|
||||
|
||||
Reference in New Issue
Block a user