Skip to content

Commit

Permalink
Get tox -e py312-integration passing. (#2180)
Browse files Browse the repository at this point in the history
CI uses `tox -e py312-pip23_2-integration`, but for local dev runs
`tox -e py312-integration` is more typical. Get this green by ensuring
the reproducible build tests use a consistent Pip version since
`pip wheel` has varying output for certain metadata files (line order
and whitespace vary) across Pip / Setuptools / Wheel versions.
  • Loading branch information
jsirois authored Jul 21, 2023
1 parent de7e6ec commit 309ac9e
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions tests/integration/test_reproducible.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

from pex.common import temporary_dir
from pex.compatibility import PY2
from pex.interpreter import PythonInterpreter
from pex.pip.version import PipVersion, PipVersionValue
from pex.targets import LocalInterpreter
from pex.testing import (
IS_LINUX_ARM64,
IS_MAC_ARM64,
Expand All @@ -31,6 +34,23 @@
from typing import Iterable, List, Optional, Tuple


def compatible_pip_version(pythons):
# type: (Iterable[str]) -> PipVersionValue
for pip_version in PipVersion.values():
if all(
pip_version.requires_python_applies(
LocalInterpreter.create(PythonInterpreter.from_binary(python))
)
for python in pythons
):
return pip_version
raise AssertionError(
"Expected there to be a --pip-version compatible with all pythons: {pythons}".format(
pythons=", ".join(pythons)
)
)


def assert_reproducible_build(
args, # type: List[str]
pythons=None, # type: Optional[Iterable[str]]
Expand Down Expand Up @@ -134,7 +154,14 @@ def test_reproducible_build_sdist_requirements(major_compatible_pythons):
# type: (Tuple[str, ...]) -> None
# The python-crontab sdist will be built as py2-none-any or py3-none-any depending on the
# Python major version since it is not marked as universal in the sdist.
assert_reproducible_build(["python-crontab==2.3.6"], pythons=major_compatible_pythons)
assert_reproducible_build(
[
"python-crontab==2.3.6",
"--pip-version",
str(compatible_pip_version(major_compatible_pythons)),
],
pythons=major_compatible_pythons,
)


def test_reproducible_build_m_flag(mixed_major_pythons):
Expand Down Expand Up @@ -170,7 +197,13 @@ def do_something():
{"setup.cfg": setup_cfg, "setup.py": setup_py, "my_app.py": my_app}
) as project_dir:
assert_reproducible_build(
[project_dir, "-c", "my_app_function"],
[
project_dir,
"-c",
"my_app_function",
"--pip-version",
str(compatible_pip_version(major_compatible_pythons)),
],
# Modern Pip / Setuptools produce different metadata for sdists than legacy Pip /
# Setuptools; so we don't mix them.
pythons=major_compatible_pythons,
Expand All @@ -182,7 +215,14 @@ def test_reproducible_build_c_flag_from_dependency(major_compatible_pythons):
# The futurize script installed depends on the version of python being used; so we don't try
# to mix Python 2 with Python 3 as in many other reproducibility tests.
assert_reproducible_build(
["future==0.17.1", "-c", "futurize"], pythons=major_compatible_pythons
[
"future==0.17.1",
"-c",
"futurize",
"--pip-version",
str(compatible_pip_version(major_compatible_pythons)),
],
pythons=major_compatible_pythons,
)


Expand Down

0 comments on commit 309ac9e

Please sign in to comment.