Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/generate_pyodide_constraints.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import inspect
import sys
import textwrap
from pathlib import Path

import click
Expand Down Expand Up @@ -51,7 +51,7 @@ def generate_pyodide_constraints(pyodide_version: str, output_file: str | None =

pyodide_build_specifier = ",".join(pyodide_build_specifier_parts)

constraints_txt = textwrap.dedent(f"""
constraints_txt = inspect.cleandoc(f"""
pip
build[virtualenv]
pyodide-build{pyodide_build_specifier}
Expand Down
5 changes: 5 additions & 0 deletions cibuildwheel/resources/constraints-pyodide312.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

pip
build[virtualenv]
pyodide-build>=0.26.0
click<8.2
5 changes: 5 additions & 0 deletions cibuildwheel/resources/constraints-pyodide313.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

pip
build[virtualenv]
pyodide-build>=0.26.0
click<8.2
18 changes: 17 additions & 1 deletion cibuildwheel/util/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path, PurePath
from typing import Any, Literal, Self, TypeVar

import packaging.requirements
from packaging.utils import parse_wheel_filename

from . import resources
Expand Down Expand Up @@ -80,8 +81,23 @@ def get_for_python_version(
self, *, version: str, variant: Literal["python", "pyodide"] = "python", tmp_dir: Path
) -> Path | None:
if self.packages:
file_name = (
resources.PATH / f"constraints-pyodide{version}.in"
if variant == "pyodide"
else resources.CONSTRAINTS_IN
)
input_packages = (
s.strip() for s in file_name.joinpath(file_name).read_text().splitlines()
)
input_requirements = (
packaging.requirements.Requirement(s)
for s in input_packages
if s and not s.startswith("#")
)
packages = [*self.packages, *(str(r) for r in input_requirements if r.specifier)]

constraint_file = tmp_dir / "constraints.txt"
constraint_file.write_text("\n".join(self.packages))
constraint_file.write_text("\n".join(packages))
return constraint_file

if self.base_file_path is not None:
Expand Down
1 change: 1 addition & 0 deletions cibuildwheel/util/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PINNED_DOCKER_IMAGES: Final[Path] = PATH / "pinned_docker_images.cfg"
BUILD_PLATFORMS: Final[Path] = PATH / "build-platforms.toml"
CONSTRAINTS: Final[Path] = PATH / "constraints.txt"
CONSTRAINTS_IN: Final[Path] = PATH / "constraints.in"
VIRTUALENV: Final[Path] = PATH / "virtualenv.toml"
CIBUILDWHEEL_SCHEMA: Final[Path] = PATH / "cibuildwheel.schema.json"
PYTHON_BUILD_STANDALONE_RELEASES: Final[Path] = PATH / "python-build-standalone-releases.json"
Expand Down
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def update_constraints(session: nox.Session) -> None:
python_version = ".".join(pyodide["version"].split(".")[:2])
pyodide_version = pyodide["default_pyodide_version"]

tmp_file = Path(session.create_tmp()) / "constraints-pyodide.in"
in_file = resources / f"constraints-pyodide{python_version.replace('.', '')}.in"

session.run(
"python",
"bin/generate_pyodide_constraints.py",
"--output-file",
tmp_file,
in_file,
pyodide_version,
)

Expand All @@ -122,7 +122,7 @@ def update_constraints(session: nox.Session) -> None:
"compile",
f"--python-version={python_version}",
"--upgrade",
tmp_file,
in_file,
f"--output-file={output_file}",
env=env,
)
Expand Down
Loading