8000 install build in target environment by dholth · Pull Request #30 · dholth/conda-pupa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

install build in target environment #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion conda_pupa/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ def build_pypa(
builder = ProjectBuilder(path, python_executable=python_executable)

build_system_requires = builder.build_system_requires
missing = dependencies.check_dependencies(build_system_requires, prefix=prefix)
for _retry in range(2):
try:
missing = dependencies.check_dependencies(
build_system_requires, prefix=prefix
)
break
except dependencies.MissingDependencyError as e:
dependencies.ensure_requirements(e.dependencies, prefix=prefix)

print("Installing requirements for build system:", missing)
# does flatten() work for a deeper dependency chain?
dependencies.ensure_requirements(flatten(missing), prefix=prefix)
Expand Down
21 changes: 16 additions & 5 deletions conda_pupa/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import importlib.resources
import json
import subprocess
import sys
from pathlib import Path
from typing import Iterable

Expand All @@ -16,6 +15,15 @@
from .translate import requires_to_conda


class MissingDependencyError(Exception):
"""
When the dependency subprocess can't run.
"""

def __init__(self, dependencies: list[str]):
self.dependencies = dependencies


def check_dependencies(requirements: Iterable[str], prefix: Path):
python_executable = str(paths.get_python_executable(prefix))
dependency_getter = importlib.resources.read_text(
Expand All @@ -36,10 +44,13 @@ def check_dependencies(requirements: Iterable[str], prefix: Path):
check=True,
)
missing = json.loads(result.stdout)
except subprocess.SubprocessError as e:
# XXX what exception to raise?
print(e, file=sys.stderr)
return []
except subprocess.CalledProcessError as e:
if (
"ModuleNotFound" in e.stderr
): # Missing 'build' dependency aka 'python-build' in conda land
raise MissingDependencyError(["build"]) from e
else:
raise

return missing

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ classifiers = [
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"build", # conda name is python-build
"build", # conda name is python-build
"conda-index",
"conda-libmamba-solver >=24.9",
"conda-package-streaming >=0.11",
"installer >=0.7", # conda name is python-installer
"installer >=0.7", # conda name is python-installer
"packaging >=24",
"unearth >=0.17.2", # download packages from pypi
"unearth >=0.17.2", # download packages from pypi
]

[project.optional-dependencies]
Expand Down
Loading
0