From 94b7f9652d2fe36a2b219a15dbf84c86a28fcfc9 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 15:20:43 +0000 Subject: [PATCH 1/6] Update .gitattributes: exclude tests and workflows from archive meson-python uses git-archive to create the sdist. Some of euphonic's test files are on the large side and we don't need to include them with every copy of the source. This does have the downside that git-archive can no longer be used to produce a copy of the source with tests, but we weren't using that anyway. --- .gitattributes | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 6cec1af8d..7ce627887 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ -# Added by versioneer -euphonic/_version.py export-subst +.github/** export-ignore +tests_and_analysis/** export-ignore +tox.ini export-ignore From feab9e3462637da96cba228da538956580385b94 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 15:34:32 +0000 Subject: [PATCH 2/6] Run wheel tests from main project directory --- .github/workflows/build_upload_pypi_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_upload_pypi_wheels.yml b/.github/workflows/build_upload_pypi_wheels.yml index 3f570b1d4..4d22f0e42 100644 --- a/.github/workflows/build_upload_pypi_wheels.yml +++ b/.github/workflows/build_upload_pypi_wheels.yml @@ -124,7 +124,7 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib" - CIBW_TEST_COMMAND: python {package}/tests_and_analysis/test/run_tests.py + CIBW_TEST_COMMAND: python ${{ github.workspace }}/tests_and_analysis/test/run_tests.py with: output-dir: wheelhouse From d5b78e374618d28279a4f7e816fc4e4ba0d1d2f5 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 16:02:21 +0000 Subject: [PATCH 3/6] Manipulate source path for wheel tests --- .github/workflows/build_upload_pypi_wheels.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_upload_pypi_wheels.yml b/.github/workflows/build_upload_pypi_wheels.yml index 4d22f0e42..0dde5252b 100644 --- a/.github/workflows/build_upload_pypi_wheels.yml +++ b/.github/workflows/build_upload_pypi_wheels.yml @@ -57,10 +57,12 @@ jobs: steps: - name: Checkout project (for test files) uses: actions/checkout@v4 + with: + path: euphonic_from_git - name: Delete source (to ensure we are using sdist only) shell: bash -l {0} - run: rm -rf euphonic + run: rm -rf euphonic_from_git/euphonic - name: Download sdist uses: actions/download-artifact@v4 @@ -113,6 +115,10 @@ jobs: run: | python -m pip install --upgrade pip build wheel twine + - name: List contents of GITHUB_WORKSPACE + shell: bash -l {0} + run: ls -R ${GITHUB_WORKSPACE} + - name: Build wheels from sdist uses: pypa/cibuildwheel@v2.21.3 env: @@ -124,7 +130,7 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib" - CIBW_TEST_COMMAND: python ${{ github.workspace }}/tests_and_analysis/test/run_tests.py + CIBW_TEST_COMMAND: python ${{ github.workspace }}/euphonic_from_git/tests_and_analysis/test/run_tests.py with: output-dir: wheelhouse From ceb0b89b600ee14dcd1a756819f4b772621b9720 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 16:45:37 +0000 Subject: [PATCH 4/6] Use {project} instead of abs path Maybe abs paths don't work well here for some reason? --- .github/workflows/build_upload_pypi_wheels.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build_upload_pypi_wheels.yml b/.github/workflows/build_upload_pypi_wheels.yml index 0dde5252b..648456818 100644 --- a/.github/workflows/build_upload_pypi_wheels.yml +++ b/.github/workflows/build_upload_pypi_wheels.yml @@ -115,10 +115,6 @@ jobs: run: | python -m pip install --upgrade pip build wheel twine - - name: List contents of GITHUB_WORKSPACE - shell: bash -l {0} - run: ls -R ${GITHUB_WORKSPACE} - - name: Build wheels from sdist uses: pypa/cibuildwheel@v2.21.3 env: @@ -130,7 +126,7 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib" - CIBW_TEST_COMMAND: python ${{ github.workspace }}/euphonic_from_git/tests_and_analysis/test/run_tests.py + CIBW_TEST_COMMAND: python {project}/euphonic_from_git/tests_and_analysis/test/run_tests.py with: output-dir: wheelhouse From 87bd2b2285f06aa1bcd4a389adcf898ee65bd1be Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 16:55:05 +0000 Subject: [PATCH 5/6] Try {package} as ref point --- .github/workflows/build_upload_pypi_wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_upload_pypi_wheels.yml b/.github/workflows/build_upload_pypi_wheels.yml index 648456818..6f492d94b 100644 --- a/.github/workflows/build_upload_pypi_wheels.yml +++ b/.github/workflows/build_upload_pypi_wheels.yml @@ -126,7 +126,7 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib" - CIBW_TEST_COMMAND: python {project}/euphonic_from_git/tests_and_analysis/test/run_tests.py + CIBW_TEST_COMMAND: "python {package}../../euphonic_from_git/tests_and_analysis/test/run_tests.py" with: output-dir: wheelhouse From 25475fa8571a83847c51d5f383b695314f1c85e2 Mon Sep 17 00:00:00 2001 From: "Adam J. Jackson" Date: Tue, 10 Dec 2024 17:17:12 +0000 Subject: [PATCH 6/6] Build wheels from git checkout While the purity of building from sdist was appealing, it is difficult for cibuildwheel to cleanly run an external test suite as it containerizes the Linux build (to deal with ManyLinux requirements). We are still testing the sdist (on Windows) so just have to trust in cibuildwheel's own efforts to separate the testing and source from the installation. (Which it does seem to work quite hard at.) --- .../workflows/build_upload_pypi_wheels.yml | 66 +++++++------------ 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build_upload_pypi_wheels.yml b/.github/workflows/build_upload_pypi_wheels.yml index 6f492d94b..e5893a472 100644 --- a/.github/workflows/build_upload_pypi_wheels.yml +++ b/.github/workflows/build_upload_pypi_wheels.yml @@ -6,29 +6,7 @@ on: workflow_dispatch: jobs: - build-sdist: - name: Build sdist - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Ensure tags are fetched for versioning - - - name: Create source distribution - shell: bash -l {0} - run: | - pipx run build --sdist . - - - name: Upload source dist as build artifact - uses: actions/upload-artifact@v4 - with: - name: python-source-distribution - path: dist/ - if-no-files-found: error - build-wheels: - needs: build-sdist strategy: matrix: os: [windows-latest, macos-13, macos-latest, ubuntu-latest] @@ -57,23 +35,6 @@ jobs: steps: - name: Checkout project (for test files) uses: actions/checkout@v4 - with: - path: euphonic_from_git - - - name: Delete source (to ensure we are using sdist only) - shell: bash -l {0} - run: rm -rf euphonic_from_git/euphonic - - - name: Download sdist - uses: actions/download-artifact@v4 - with: - name: python-source-distribution - path: dist/ - - - name: Get sdist filename - shell: bash -l {0} - run: | - echo EUPHONIC_SDIST="$(find dist/ -name 'euphonic*.tar.gz')" >> $GITHUB_ENV - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 @@ -115,7 +76,7 @@ jobs: run: | python -m pip install --upgrade pip build wheel twine - - name: Build wheels from sdist + - name: Build wheels from git checkout uses: pypa/cibuildwheel@v2.21.3 env: CIBW_BUILD_FRONTEND: build @@ -126,11 +87,10 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib" - CIBW_TEST_COMMAND: "python {package}../../euphonic_from_git/tests_and_analysis/test/run_tests.py" + CIBW_TEST_COMMAND: "python {package}/tests_and_analysis/test/run_tests.py" with: output-dir: wheelhouse - package-dir: ${{ env.EUPHONIC_SDIST }} - name: Upload wheels as build artifacts uses: actions/upload-artifact@v4 @@ -139,6 +99,27 @@ jobs: path: wheelhouse/*-${{ matrix.wheelname }}*_${{ matrix.cibw_archs }}.whl if-no-files-found: error + build-sdist: + name: Build sdist + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Ensure tags are fetched for versioning + + - name: Create source distribution + shell: bash -l {0} + run: | + pipx run build --sdist . + + - name: Upload source dist as build artifact + uses: actions/upload-artifact@v4 + with: + name: python-source-distribution + path: dist/ + if-no-files-found: error + test-sdist: needs: build-sdist name: Test build from sdist on Windows @@ -196,7 +177,6 @@ jobs: shell: bash -l {0} run: python tests_and_analysis/test/run_tests.py --report - publish: if: github.event_name == 'release' needs: [build-wheels,test-sdist]