refactor: pull out dependency_constraint (#2347)
* refactor: pull out dependency_constraint Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * refactor: address feedback Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> * ci: better parallel Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
import tomllib
|
||||
from collections.abc import Sequence, Set
|
||||
from collections.abc import Set
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
@@ -18,7 +18,6 @@ from ..frontend import BuildFrontendConfig, get_build_frontend_extra_flags
|
||||
from ..logger import log
|
||||
from ..options import Options
|
||||
from ..selector import BuildSelector
|
||||
from ..typing import PathOrStr
|
||||
from ..util import resources
|
||||
from ..util.cmd import call, shell
|
||||
from ..util.file import (
|
||||
@@ -31,7 +30,7 @@ from ..util.file import (
|
||||
)
|
||||
from ..util.helpers import prepare_command
|
||||
from ..util.packaging import combine_constraints, find_compatible_wheel, get_pip_version
|
||||
from ..venv import virtualenv
|
||||
from ..venv import constraint_flags, virtualenv
|
||||
|
||||
IS_WIN: Final[bool] = sys.platform.startswith("win")
|
||||
|
||||
@@ -145,14 +144,14 @@ def get_base_python(identifier: str) -> Path:
|
||||
def setup_python(
|
||||
tmp: Path,
|
||||
python_configuration: PythonConfiguration,
|
||||
dependency_constraint_flags: Sequence[PathOrStr],
|
||||
constraints_path: Path | None,
|
||||
environment: ParsedEnvironment,
|
||||
) -> dict[str, str]:
|
||||
base_python = get_base_python(python_configuration.identifier)
|
||||
|
||||
log.step("Setting up build environment...")
|
||||
venv_path = tmp / "venv"
|
||||
env = virtualenv(python_configuration.version, base_python, venv_path, [], use_uv=False)
|
||||
env = virtualenv(python_configuration.version, base_python, venv_path, None, use_uv=False)
|
||||
venv_bin_path = venv_path / "bin"
|
||||
assert venv_bin_path.exists()
|
||||
env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"
|
||||
@@ -166,7 +165,7 @@ def setup_python(
|
||||
"install",
|
||||
"--upgrade",
|
||||
"pip",
|
||||
*dependency_constraint_flags,
|
||||
*constraint_flags(constraints_path),
|
||||
env=env,
|
||||
cwd=venv_path,
|
||||
)
|
||||
@@ -198,7 +197,7 @@ def setup_python(
|
||||
"auditwheel-emscripten",
|
||||
"build[virtualenv]",
|
||||
"pyodide-build",
|
||||
*dependency_constraint_flags,
|
||||
*constraint_flags(constraints_path),
|
||||
env=env,
|
||||
)
|
||||
|
||||
@@ -269,14 +268,11 @@ def build(options: Options, tmp_path: Path) -> None:
|
||||
constraints_path = build_options.dependency_constraints.get_for_python_version(
|
||||
version=config.version, variant="pyodide", tmp_dir=identifier_tmp_dir
|
||||
)
|
||||
dependency_constraint_flags: Sequence[PathOrStr] = (
|
||||
["-c", constraints_path] if constraints_path else []
|
||||
)
|
||||
|
||||
env = setup_python(
|
||||
identifier_tmp_dir / "build",
|
||||
config,
|
||||
dependency_constraint_flags,
|
||||
constraints_path,
|
||||
build_options.environment,
|
||||
)
|
||||
pip_version = get_pip_version(env)
|
||||
|
||||
Reference in New Issue
Block a user