Skip to content

Commit a1e3efb

Browse files
fix: correct path when building sdist package (#1687)
* Edit path when building sdist package This patch changes the working directory from the temp to the project when building sdist package.This resolves issues with relative paths in configuration files. Resolves #1683 * Add a test for the `package` placeholder exposure The change extends the existing test — `test_simple`. It checks that the temporary wheel build directory is the project root extracted from the source distribution. It does so by testing the presence of the `setup.py` in the current working directory, as a side effect. * Edit quotes in the CLI argument for Windows compatibility Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> * Use single quotes to avoid syntax errors from f-string Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]> --------- Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
1 parent c0e4b16 commit a1e3efb

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cibuildwheel/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def main() -> None:
160160
# This is now the new package dir
161161
args.package_dir = project_dir.resolve()
162162

163-
with chdir(temp_dir):
163+
with chdir(project_dir):
164164
build_in_directory(args)
165165
finally:
166166
# avoid https://github.com/python/cpython/issues/86962 by performing

test/test_from_sdist.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,23 @@ def test_simple(tmp_path):
6161
sdist_dir.mkdir()
6262
sdist_path = make_sdist(basic_project, sdist_dir)
6363

64+
setup_py_assertion_snippet = textwrap.dedent(
65+
"""
66+
import os
67+
68+
assert os.path.exists('setup.py')
69+
assert os.path.exists('{package}/setup.py')
70+
""",
71+
)
72+
setup_py_assertion_cmd = f'python3 -c "{setup_py_assertion_snippet !s}"'
73+
6474
# build the wheels from sdist
6575
actual_wheels = cibuildwheel_from_sdist_run(
6676
sdist_path,
67-
add_env={"CIBW_BUILD": "cp39-*"},
77+
add_env={
78+
"CIBW_BEFORE_BUILD": setup_py_assertion_cmd,
79+
"CIBW_BUILD": "cp39-*",
80+
},
6881
)
6982

7083
# check that the expected wheels are produced

0 commit comments

Comments
 (0)