Skip to content

Commit

Permalink
Merge pull request #541 from lesteve/pip-finds-recent-manylinux-wheels
Browse files Browse the repository at this point in the history
Make recent manylinux wheels findable by pypi_resolver
  • Loading branch information
maresb committed Oct 27, 2023
2 parents 9ff72d7 + 4ad59d6 commit f53dd00
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
6 changes: 4 additions & 2 deletions conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
from packaging.tags import Tag


# NB: in principle these depend on the glibc in the conda env
MANYLINUX_TAGS = ["1", "2010", "2014", "_2_17"]
# NB: in principle these depend on the glibc on the machine creating the conda env.
# We use tags supported by manylinux Docker images, which are likely the most common
# in practice, see https://github.com/pypa/manylinux/blob/main/README.rst#docker-images.
MANYLINUX_TAGS = ["1", "2010", "2014", "_2_17", "_2_24", "_2_28"]
# This needs to be updated periodically as new macOS versions are released.
MACOS_VERSION = (13, 4)

Expand Down
8 changes: 8 additions & 0 deletions tests/test-pip-finds-recent-manylinux-wheels/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# environment.yml
channels:
- conda-forge

dependencies:
- pip
- pip:
- lightgbm
36 changes: 36 additions & 0 deletions tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import pathlib
import platform
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -299,6 +300,13 @@ def pip_conda_name_confusion(tmp_path: Path):
)


@pytest.fixture
def lightgbm_environment(tmp_path: Path):
return clone_test_dir("test-pip-finds-recent-manylinux-wheels", tmp_path).joinpath(
"environment.yml"
)


@pytest.fixture
def multi_source_env(tmp_path: Path):
f = clone_test_dir("test-multi-sources", tmp_path)
Expand Down Expand Up @@ -2293,3 +2301,31 @@ def test_cli_version(capsys: "pytest.CaptureFixture[str]"):
# the part before, in this case just "0.11.3".
version_without_dev = __version__.split(".dev")[0]
assert version_without_dev in result.stdout


def test_pip_finds_recent_manylinux_wheels(
monkeypatch: "pytest.MonkeyPatch", lightgbm_environment: Path, conda_exe: str
):
"""Ensure that we find a manylinux wheel with glibc > 2.17 for lightgbm.
See https://github.com/conda/conda-lock/issues/517 for more context.
If not found, installation would trigger a build of lightgbm from source.
If this test fails, it likely means that MANYLINUX_TAGS in
`conda_lock/pypi_solver.py` is out of date.
"""
monkeypatch.chdir(lightgbm_environment.parent)
run_lock([lightgbm_environment], conda_exe=conda_exe, platforms=["linux-64"])
lockfile = parse_conda_lock_file(
lightgbm_environment.parent / DEFAULT_LOCKFILE_NAME
)

(lightgbm_dep,) = [p for p in lockfile.package if p.name == "lightgbm"]
manylinux_pattern = r"manylinux_(\d+)_(\d+).+\.whl"
manylinux_match = re.search(manylinux_pattern, lightgbm_dep.url)
assert manylinux_match, "No match found for manylinux version in {lightgbm_dep.url}"

manylinux_version = [int(each) for each in manylinux_match.groups()]
# Make sure the manylinux wheel was built with glibc > 2.17 as a
# non-regression test for #517
assert manylinux_version > [2, 17]

0 comments on commit f53dd00

Please sign in to comment.