-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test sdist builds; reduce sdist size (#337)
## Fix bug in build_utils/version.py build_utils/version.py was raising errors in scenarios where git is unavailable. This happens more on Windows because 3 different names for git are attempted. ## Add windows sdist testing to pypi wheels workflow Wheels are already tested by cibuildwheel but a separate action is now used to test the source build. This test runs on Windows as this was the most vulnerable to the fixed bug ## Update .gitattributes: exclude tests, docs 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.
- Loading branch information
Showing
5 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Added by versioneer | ||
euphonic/_version.py export-subst | ||
.github/** export-ignore | ||
doc/** export-ignore | ||
tests_and_analysis/** export-ignore | ||
tox.ini export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
build-wheels: | ||
strategy: | ||
matrix: | ||
os: [windows-latest, macos-13, macos-latest, ubuntu-latest] | ||
|
@@ -33,13 +33,14 @@ jobs: | |
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Ensure tags are fetched for versioning | ||
- name: Checkout project (for test files) | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install llvm on Macos | ||
if: startsWith(matrix.os, 'macos') | ||
shell: bash -l {0} | ||
|
@@ -75,7 +76,7 @@ jobs: | |
run: | | ||
python -m pip install --upgrade pip build wheel twine | ||
- name: Build wheels | ||
- name: Build wheels from git checkout | ||
uses: pypa/[email protected] | ||
env: | ||
CIBW_BUILD_FRONTEND: build | ||
|
@@ -86,34 +87,99 @@ 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 {package}/tests_and_analysis/test/run_tests.py" | ||
|
||
with: | ||
output-dir: wheelhouse | ||
|
||
- name: Upload wheels as build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}-${{ matrix.cibw_archs }} | ||
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 | ||
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | ||
shell: bash -l {0} | ||
run: | | ||
python -m build --sdist . | ||
pipx run build --sdist . | ||
- name: Upload source dist as build artifact | ||
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' && github.event_name == 'release' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-source-distribution | ||
path: dist | ||
path: dist/ | ||
if-no-files-found: error | ||
|
||
- name: Upload wheels as build artifacts | ||
uses: actions/upload-artifact@v4 | ||
test-sdist: | ||
needs: build-sdist | ||
name: Test build from sdist on Windows | ||
runs-on: windows-latest | ||
steps: | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}-${{ matrix.cibw_archs }} | ||
path: wheelhouse/*-${{ matrix.wheelname }}*_${{ matrix.cibw_archs }}.whl | ||
if-no-files-found: error | ||
python-version: 3.11 | ||
|
||
- name: Find MSVC and set environment variables | ||
shell: bash -l {0} | ||
env: | ||
MSVC_PREFIX: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC' | ||
run: | | ||
echo "Available MSVC installations:" | ||
ls "$MSVC_PREFIX" | ||
MSVC_BIN=$(ls "$MSVC_PREFIX" | tail -n 1)\\bin\\HostX64\\x64 | ||
CC="$MSVC_PREFIX\\$MSVC_BIN\\cl.exe" | ||
echo "CC: $CC" | ||
echo "CC=$CC" >> $GITHUB_ENV | ||
CC_LD="$MSVC_PREFIX\\$MSVC_BIN\\link.exe" | ||
echo "CC_LD: $CC_LD" | ||
echo "CC_LD=$CC_LD" >> $GITHUB_ENV | ||
- name: Download sdist | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: dist/ | ||
merge-multiple: true | ||
|
||
- name: List downloaded sdist | ||
run: | | ||
ls -R dist/ | ||
- name: Update pip | ||
shell: bash -l {0} | ||
run: | | ||
python -m pip install --upgrade pip | ||
- name: Install from sdist | ||
shell: bash -l {0} | ||
run: python -m pip install $(find dist -name 'euphonic-*.tar.gz')[matplotlib,phonopy_reader,brille,test] | ||
|
||
- name: Checkout repository (for tests and test data) | ||
uses: actions/checkout@v4 | ||
|
||
- name: Delete source (to ensure we are testing INSTALLED version) | ||
shell: bash -l {0} | ||
run: rm -rf euphonic | ||
|
||
- name: run tests | ||
shell: bash -l {0} | ||
run: python tests_and_analysis/test/run_tests.py --report | ||
|
||
publish: | ||
if: github.event_name == 'release' | ||
needs: build | ||
needs: [build-wheels,test-sdist] | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
environment: | ||
|
@@ -134,7 +200,7 @@ jobs: | |
merge-multiple: true | ||
|
||
- name: List Files | ||
run: ls -R | ||
run: ls -R dist/ | ||
|
||
- name: Upload wheels to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
mock | ||
pytest~=7.0 | ||
pytest==7.* | ||
coverage | ||
pytest-mock | ||
pytest-lazy-fixture | ||
pytest-xvfb | ||
python-slugify | ||
toolz | ||
wheel==0.43 | ||
setuptools==71.1.0 |