From cc3fd8ce0618de4a09d0d98be23ea7931fbd698c Mon Sep 17 00:00:00 2001 From: Olena Date: Wed, 6 Dec 2023 00:30:21 +0200 Subject: [PATCH 1/4] 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 --- cibuildwheel/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index c6a2fdeaa..03b471447 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -160,7 +160,7 @@ def main() -> None: # This is now the new package dir args.package_dir = project_dir.resolve() - with chdir(temp_dir): + with chdir(project_dir): build_in_directory(args) finally: # avoid https://github.com/python/cpython/issues/86962 by performing From a55a8ac9da24f08b3b18f82f097170335f92e74c Mon Sep 17 00:00:00 2001 From: Olena Date: Mon, 22 Jan 2024 23:14:02 +0200 Subject: [PATCH 2/4] Add a test for the `package` placeholder exposure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- test/test_from_sdist.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index f0b7e93e8..c09811efc 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -61,10 +61,23 @@ def test_simple(tmp_path): sdist_dir.mkdir() sdist_path = make_sdist(basic_project, sdist_dir) + setup_py_assertion_snippet = textwrap.dedent( + """ + import os + + assert os.path.exists("setup.py") + assert os.path.exists("{package}/setup.py") + """, + ) + setup_py_assertion_cmd = f"python3 -c '{setup_py_assertion_snippet !s}'" + # build the wheels from sdist actual_wheels = cibuildwheel_from_sdist_run( sdist_path, - add_env={"CIBW_BUILD": "cp39-*"}, + add_env={ + "CIBW_BEFORE_BUILD": setup_py_assertion_cmd, + "CIBW_BUILD": "cp39-*", + }, ) # check that the expected wheels are produced From ca3ade649a3f2a38cedf7ca75de4fb077f3030c9 Mon Sep 17 00:00:00 2001 From: Olena <107187316+OlenaYefymenko@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:40:47 +0200 Subject: [PATCH 3/4] Edit quotes in the CLI argument for Windows compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- test/test_from_sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index c09811efc..e8b26fe57 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -69,7 +69,7 @@ def test_simple(tmp_path): assert os.path.exists("{package}/setup.py") """, ) - setup_py_assertion_cmd = f"python3 -c '{setup_py_assertion_snippet !s}'" + setup_py_assertion_cmd = f'python3 -c "{setup_py_assertion_snippet !s}"' # build the wheels from sdist actual_wheels = cibuildwheel_from_sdist_run( From bfc77bef397bd382876b42f38a6e6238322de6f0 Mon Sep 17 00:00:00 2001 From: Olena <107187316+OlenaYefymenko@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:12:40 +0200 Subject: [PATCH 4/4] Use single quotes to avoid syntax errors from f-string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- test/test_from_sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_from_sdist.py b/test/test_from_sdist.py index e8b26fe57..0021a2acb 100644 --- a/test/test_from_sdist.py +++ b/test/test_from_sdist.py @@ -65,8 +65,8 @@ def test_simple(tmp_path): """ import os - assert os.path.exists("setup.py") - assert os.path.exists("{package}/setup.py") + assert os.path.exists('setup.py') + assert os.path.exists('{package}/setup.py') """, ) setup_py_assertion_cmd = f'python3 -c "{setup_py_assertion_snippet !s}"'