Skip to content
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

fix: install our dependencies outside the project directory #1488

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 11 additions & 4 deletions cibuildwheel/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,20 @@ def build_in_container(

# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
container.call(["pip", "install", "virtualenv", *dependency_constraint_flags], env=env)
container.call(
["pip", "install", "virtualenv", *dependency_constraint_flags], env=env, cwd="/"
)

testing_temp_dir = PurePosixPath(
container.call(["mktemp", "-d"], capture_output=True).strip()
container.call(["mktemp", "-d"], capture_output=True, cwd="/").strip()
)
venv_dir = testing_temp_dir / "venv"

container.call(["python", "-m", "virtualenv", "--no-download", venv_dir], env=env)
container.call(
["python", "-m", "virtualenv", "--no-download", venv_dir],
env=env,
cwd="/",
)

virtualenv_env = env.copy()
virtualenv_env["PATH"] = f"{venv_dir / 'bin'}:{virtualenv_env['PATH']}"
Expand All @@ -336,8 +342,9 @@ def build_in_container(
# Let's just pick the first one.
wheel_to_test = repaired_wheels[0]
container.call(
["pip", "install", str(wheel_to_test) + build_options.test_extras],
["pip", "install", f"{wheel_to_test}{build_options.test_extras}"],
env=virtualenv_env,
cwd="/",
)

# Install any requirements to run the tests
Expand Down
14 changes: 12 additions & 2 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def setup_python(
"delocate",
*dependency_constraint_flags,
env=env,
cwd="/",
)
elif build_frontend == "build":
call(
Expand All @@ -302,6 +303,7 @@ def setup_python(
"build[virtualenv]",
*dependency_constraint_flags,
env=env,
cwd="/",
)
else:
assert_never(build_frontend)
Expand Down Expand Up @@ -538,7 +540,14 @@ def build(options: Options, tmp_path: Path) -> None:

# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call("pip", "install", "virtualenv", *dependency_constraint_flags, env=env)
call(
"pip",
"install",
"virtualenv",
*dependency_constraint_flags,
env=env,
cwd="/",
)

venv_dir = identifier_tmp_dir / "venv-test"

Expand Down Expand Up @@ -582,8 +591,9 @@ def build(options: Options, tmp_path: Path) -> None:
call_with_arch(
"pip",
"install",
f"{repaired_wheel}{build_options.test_extras}",
f"{repaired_wheel.resolve()}{build_options.test_extras}",
env=virtualenv_env,
cwd="/",
)

# test the wheel
Expand Down
2 changes: 1 addition & 1 deletion cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def glob(self, path: PurePosixPath, pattern: str) -> list[PurePosixPath]:
[
self.UTILITY_PYTHON,
"-c",
f"import sys, json, glob; json.dump(glob.glob({str(glob_pattern)!r}), sys.stdout)",
f"import os, sys, json, glob; json.dump([os.path.abspath(x) for x in glob.glob({str(glob_pattern)!r})], sys.stdout)",
],
capture_output=True,
)
Expand Down
7 changes: 5 additions & 2 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def setup_python(
"wheel",
*dependency_constraint_flags,
env=env,
cwd="/",
)
elif build_frontend == "build":
call(
Expand All @@ -333,6 +334,7 @@ def setup_python(
"build[virtualenv]",
*dependency_constraint_flags,
env=env,
cwd="/",
)
else:
assert_never(build_frontend)
Expand Down Expand Up @@ -507,7 +509,7 @@ def build(options: Options, tmp_path: Path) -> None:
log.step("Testing wheel...")
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
call("pip", "install", "virtualenv", *dependency_constraint_flags, env=env)
call("pip", "install", "virtualenv", *dependency_constraint_flags, env=env, cwd="/")
venv_dir = identifier_tmp_dir / "venv-test"

# Use --no-download to ensure determinism by using seed libraries
Expand Down Expand Up @@ -537,8 +539,9 @@ def build(options: Options, tmp_path: Path) -> None:
call(
"pip",
"install",
str(repaired_wheel) + build_options.test_extras,
f"{repaired_wheel.resolve()}{build_options.test_extras}",
env=virtualenv_env,
cwd="/",
)

# test the wheel
Expand Down