Skip to content

Commit

Permalink
Migrate to CI buildwheel entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Nov 15, 2024
1 parent ff71df2 commit a538248
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
47 changes: 25 additions & 22 deletions .github/workflows/build_upload_pypi_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ jobs:
include:
- os: windows-latest
wheelname: win
cibw_archs: "AMD64"
- os: macos-13
wheelname: macos-intel
wheelname: macosx
cibw_archs: "x86_64"
- os: macos-latest
wheelname: macos-arm
wheelname: macosx
cibw_archs: "arm64"
- os: ubuntu-latest
wheelname: manylinux
cibw_archs: "x86_64"
- python-version: '3.10'
manylinux-version-tag: cp310
version-tag: cp310
- python-version: '3.11'
manylinux-version-tag: cp311
version-tag: cp311
- python-version: '3.12'
manylinux-version-tag: cp312
version-tag: cp312
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -38,6 +42,7 @@ jobs:
python-version: ${{ matrix.python-version }}
channels: conda-forge,defaults
channel-priority: true

- name: Install llvm on Macos
if: startsWith(matrix.os, 'macos')
shell: bash -l {0}
Expand All @@ -57,28 +62,25 @@ jobs:
run: |
echo "CC=${MSVC_BIN}\cl.exe" >> $GITHUB_ENV
echo "CC_LD=${MSVC_BIN}\link.exe" >> $GITHUB_ENV
- name: Update Python pip, build, wheel, and twine
shell: bash -l {0}
run: |
python -m pip install --upgrade pip build wheel twine
- name: Build Python wheel
if: matrix.os != 'ubuntu-latest'
shell: bash -l {0}
- name: Build wheels
uses: pypa/[email protected]
env:
NUMPY_VERSION: 2.0
run: |
# Build against lowest required Numpy version
python -m pip install numpy==${NUMPY_VERSION}
python -m build -o wheelhouse --wheel .
CIBW_BUILD_FRONTEND: build
CIBW_BUILD: ${{ matrix.version-tag }}-*
CIBW_ARCHS: ${{ matrix.cibw_archs }}

CIBW_CONFIG_SETTINGS_WINDOWS: "setup-args=--vsenv"
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""

CIBW_TEST_EXTRAS: "test,brille,phonopy_reader,matplotlib"
CIBW_TEST_COMMAND: pytest {package}/tests_and_analysis/test

- name: Build manylinux Python wheel
if: matrix.os == 'ubuntu-latest'
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.manylinux-version-tag}}-manylinux*
CIBW_BEFORE_BUILD: python -m pip install numpy==2.0
CIBW_ARCHS: x86_64
with:
output-dir: wheelhouse

Expand All @@ -98,8 +100,9 @@ jobs:
- name: Upload wheels as build artifacts
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}
path: wheelhouse/*-${{ matrix.wheelname }}*.whl
name: wheel-${{ matrix.wheelname }}-${{ matrix.python-version }}-${{ matrix.cibw_archs }}
path: wheelhouse/*-${{ matrix.wheelname }}*_${{ matrix.cibw_archs }}.whl
if-no-files-found: error

publish:
if: github.event_name == 'release'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ jobs:
run: |
echo "CC=${MSVC_BIN}\cl.exe" >> $GITHUB_ENV
echo "CC_LD=${MSVC_BIN}\link.exe" >> $GITHUB_ENV
- name: Update pip and install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install -r tests_and_analysis/ci_requirements.txt
- name: Run tests, skip Python 3.11 unless workflow dispatch
if: github.event_name != 'workflow_dispatch'
env:
Expand All @@ -65,6 +67,7 @@ jobs:
if: github.event_name == 'workflow_dispatch'
shell: bash -l {0}
run: python -m tox

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions build_utils/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
version += f"+{dirty[0]}.{dirty[1]}{'.dirty' if len(dirty) > 2 else ''}"
break

except (OSError, subprocess.CalledProcessError):
continue
except (OSError, subprocess.CalledProcessError) as err:
print(f"Tried {gitcmd}, returned: {err}", file=sys.stderr)
else: # Can't use git
version_file = Path(__file__).parent.parent / "euphonic" / "version.py"
version = version_file.read_text().split("=")[1].strip('"\n ')
Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
project('euphonic',
'c',
version: run_command('python', 'build_utils/version.py', check: true).stdout().strip(),
meson_version: '>=1.6')
meson_version: '>=1.6',
)

build = get_option('python_only') ? disabler() : []

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ documentation = "https://euphonic.readthedocs.io/en/stable/"
matplotlib = ["matplotlib>=3.8.0"]
phonopy_reader = ["h5py>=3.6.0", "PyYAML>=6.0"]
brille = ["brille>=0.7.0"]
test = ["mock", "pytest~=7.0", "coverage", "pytest-mock", "pytest-lazy-fixture", "pytest-xvfb"]

[project.scripts]
euphonic-brille-convergence = "euphonic.cli.brille_convergence:main"
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ install_command =
--upgrade \
--upgrade-strategy eager \
{opts} \
{packages}
{packages} \
--config-setting=setup-args='--vsenv'
deps =
numpy
-r{toxinidir}/tests_and_analysis/tox_requirements.txt
Expand Down Expand Up @@ -88,7 +89,7 @@ commands =
[testenv:py310-minrequirements-linux]
whitelist_externals = rm
install_command =
python -m pip install --force-reinstall {opts} {packages}
python -m pip install --force-reinstall {opts} {packages} --config-setting=setup-args='--vsenv'
platform =
linux: linux
deps =
Expand Down

0 comments on commit a538248

Please sign in to comment.