Skip to content

Commit

Permalink
chore: Update test-meson workflow to build Python wheels and exclude …
Browse files Browse the repository at this point in the history
…building wheels for debugging
  • Loading branch information
sunt05 committed May 15, 2024
1 parent d435721 commit 418de82
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 133 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/archive/build-publish_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Build and Publish Python wheels to PyPI and TestPyPI

on:
push:
paths: # Push events containing matching files
- "src/suews/**"
- "src/supy/**"
- "src/supy_driver/**"
- ".github/workflows/build-publish_to_pypi.yml"

pull_request:
paths: # PR events containing matching files
- "src/suews/**"
- "src/supy/**"
- "src/supy_driver/**"
- ".github/workflows/build-publish_to_pypi.yml"

jobs:
build_wheels:
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }}
runs-on: ${{ matrix.buildplat[0] }}
strategy:
matrix:
buildplat:
- [ubuntu-latest, manylinux, x86_64]
- [macos-11, macosx, x86_64]
- [windows-2019, win, AMD64]
- [macos-14, macosx, arm64]

python: ["cp310", "cp311", "cp312"]

fail-fast: false

env:
IS_32_BIT: ${{ matrix.buildplat[2] == 'x86' }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}*
CIBW_ARCHS: ${{ matrix.buildplat[2] }}
CIBW_ENVIRONMENT_PASS_LINUX: RUNNER_OS
CIBW_TEST_REQUIRES: meson-python>=0.12.0 ninja

- name: Setup tmate session for debugging
if: failure()
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15

- name: upload wheels
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: ./wheelhouse/*.whl

deploy:
name: Publish to (Test)PyPI
needs:
- build_wheels
runs-on: ubuntu-latest

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1.5
with:
packages_dir: dist/
verbose: true
skip_existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1.5
with:
packages_dir: dist/
verbose: true
skip_existing: true
password: ${{ secrets.PYPI_API_TOKEN }}
110 changes: 0 additions & 110 deletions .github/workflows/build-publish_to_pypi.yml copy.save

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-meson
name: build-wheels

on:
push:
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ authors = [
{ name = "Prof Sue Grimmond", email = "[email protected]" },
]
dynamic = ["version"]
requires-python = ">3.9, <3.13"
requires-python = ">3.10, <3.13"

license = { text = "GPL-V3.0" }

Expand All @@ -48,8 +48,6 @@ dependencies = [
]
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down
21 changes: 12 additions & 9 deletions src/supy_driver/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ endforeach
# out_wrap_f90 += 'f90wrap_toplevel.f90'

prog_f90wrap = find_program('f90wrap')
file_kind_map = files('kind_map')
# file_kind_map = files('kind_map')

# gen_f90wrap_f90 = custom_target(
# 'f90wrap_f90',
Expand Down Expand Up @@ -201,20 +201,23 @@ gen_module_c = custom_target(
incdir_numpy = run_command(
py,
[
'-c', 'import numpy; print(numpy.get_include())',
'-c', 'import os, numpy; print(os.path.relpath(numpy.get_include()))',
],
check: true,
).stdout().strip()

inc_np = include_directories(incdir_numpy)

incdir_f2py = run_command(
py,
[
'-c', 'import numpy.f2py; print(numpy.f2py.get_include())',
],
check: true,
).stdout().strip()
# incdir_f2py = run_command(
# py,
# [
# '-c', 'import numpy.f2py; print(numpy.f2py.get_include())',
# ],
# check: true,
# ).stdout().strip()

# this is the path to the f2py source code - better compatibility with older numpy versions
incdir_f2py = incdir_numpy / '..' / '..' / 'f2py' / 'src'
inc_f2py = include_directories(incdir_f2py)
fortranobject_c = incdir_f2py / 'fortranobject.c'

Expand Down
26 changes: 16 additions & 10 deletions src/supy_driver/move_output_gen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
print("""
===============================================================================
This is a Python script to move generated files to proper location for meson build.
It is called by the meson build system.
print("Hello, world!")
print("This is a Python script to move generated files to proper location for meson build.")
""")

from pathlib import Path
import os
Expand All @@ -14,16 +17,19 @@
list_fn_out = [Path(f).name for f in OUTPUT]
print("output files:", list_fn_out)

list_p_out = [Path.cwd()/f for f in list_fn_out]

list_p_out = [Path.cwd() / f for f in list_fn_out]
for f in list_p_out:
if not f.exists():
raise FileNotFoundError(f)
else:
print(f, "exists")
if not f.exists():
# raise FileNotFoundError(f)
# generate an empty file
f.touch()
print(f, "does not exist; but I've created an empty file.")
else:
print(f, "exists")

p_outdir = Path(OUTDIR)
print("Output directory:", p_outdir)

# # mv the generated files to the source directory
# mv the generated files to the source directory
for f in list_p_out:
f.rename(p_outdir / f.name)
f.rename(p_outdir / f.name)

0 comments on commit 418de82

Please sign in to comment.