From 2081885ac0d4742ced28f25dd5c514a309b3e0d2 Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Wed, 1 May 2024 08:46:57 -0600 Subject: [PATCH] should do better with pypi --- .github/workflows/Publish_pyFrame3DD.yml | 45 +++++++++++++++-------- pyframe3dd/meson.build | 47 +++++++++++++----------- pyframe3dd/src/Makefile | 2 +- pyproject.toml | 16 ++++++-- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/.github/workflows/Publish_pyFrame3DD.yml b/.github/workflows/Publish_pyFrame3DD.yml index 7077f47..74e3aaa 100644 --- a/.github/workflows/Publish_pyFrame3DD.yml +++ b/.github/workflows/Publish_pyFrame3DD.yml @@ -1,37 +1,50 @@ name: Build and upload to PyPI +# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml +# Best comparable example: https://github.com/pdfo/pdfo -# Build on every branch push, tag push, and pull request change: -#on: [push, pull_request] -# Alternatively, to publish when a (published) GitHub Release is created, use the following: -on: - release: - types: - - published +# Build on every pull request (no need for every push) and release change: +on: [pull_request, release] jobs: build_wheels: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: - - name: Setup C/C++ Compiler + - name: Install compiler + if: false == contains( matrix.os, 'windows') id: install_cc - uses: rlalik/setup-cpp-compiler@v1.2 + uses: rlalik/setup-cpp-compiler@master with: - compiler: gcc #clang + compiler: clang + + - name: Install mingw-w64 on Windows + if: contains( matrix.os, 'windows') + uses: msys2/setup-msys2@v2 + with: + path-type: inherit + install: | + mingw-w64-x86_64-gcc + mingw-w64-x86_64-gcc-fortran - name: Checkout uses: actions/checkout@v4 - - name: Build wheels + - name: Build wheels mac and linux + if: false == contains( matrix.os, 'windows') + uses: pypa/cibuildwheel@v2.17.0 env: - CC: '${{ steps.install_cc.outputs.cc }}' - CXX: '${{ steps.install_cc.outputs.cxx }}' - uses: pypa/cibuildwheel@v2.16.2 + CC: ${{ steps.install_cc.outputs.cc }} + CXX: ${{ steps.install_cc.outputs.cxx }} + - name: Build wheels windows + if: contains( matrix.os, 'windows') + uses: pypa/cibuildwheel@v2.17.0 + - uses: actions/upload-artifact@v4 with: name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} @@ -41,7 +54,7 @@ jobs: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build sdist run: pipx run build --sdist diff --git a/pyframe3dd/meson.build b/pyframe3dd/meson.build index bcb71be..a803e07 100644 --- a/pyframe3dd/meson.build +++ b/pyframe3dd/meson.build @@ -8,28 +8,33 @@ py3.install_sources( subdir: 'pyframe3dd', ) -sources = ['src/py_main.c', - 'src/py_structs.h', - 'src/py_io.c', - 'src/py_io.h', - 'src/py_frame3dd.c', - 'src/py_frame3dd.h', - 'src/py_eig.c', - 'src/py_eig.h', - 'src/py_HPGmatrix.c', - 'src/py_HPGmatrix.h', - 'src/coordtrans.c', - 'src/coordtrans.h', - 'src/HPGutil.c', - 'src/HPGutil.h', - 'src/NRutil.c', - 'src/NRutil.h'] +sources = [ + 'src/HPGutil.h', + 'src/HPGutil.c', + 'src/coordtrans.h', + 'src/coordtrans.c', + 'src/NRutil.h', + 'src/NRutil.c', + 'src/py_io.h', + 'src/py_io.c', + 'src/py_eig.h', + 'src/py_eig.c', + 'src/py_structs.h', + 'src/py_HPGmatrix.h', + 'src/py_HPGmatrix.c', + 'src/py_frame3dd.h', + 'src/py_frame3dd.c', + 'src/py_main.c', +] # We need to build a shared library NOT A PYTHON EXTENSION # The ctypes wrapper handles the extension part. # If the interface was done purely in C, then need the python extension. -temp = shared_library('_pyframe3dd', sources, - name_prefix: '', - include_directories: 'src', - install_dir: py3.get_install_dir() / 'pyframe3dd', - install : true) +temp = shared_library( + '_pyframe3dd', + sources, + name_prefix: '', + include_directories: ['src','src/microstran'], + install_dir: py3.get_install_dir() / 'pyframe3dd', + install : true, +) diff --git a/pyframe3dd/src/Makefile b/pyframe3dd/src/Makefile index 3592ebd..6d05902 100644 --- a/pyframe3dd/src/Makefile +++ b/pyframe3dd/src/Makefile @@ -1,5 +1,5 @@ CC ?= clang #gcc -CFLAGS = -c -g -O2 -fPIC +CFLAGS = -c -g -O2 -fPIC -Wall OBS = coordtrans.o HPGutil.o NRutil.o PYOBS = py_main.o py_io.o py_frame3dd.o py_eig.o py_HPGmatrix.o diff --git a/pyproject.toml b/pyproject.toml index a3abfc2..4163425 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "mesonpy" [project] name = "WISDEM-pyFrame3DD" -version = "1.1.0" +version = "1.1.1" description = "Python bindings to Frame3DD, a code for static and dynamic structural analysis of 2D and 3D frames and trusses, with permission from Prof Henri Gavin" readme = "README.md" requires-python = ">=3.9" @@ -116,5 +116,15 @@ atomic = true #src_paths=isort,test [tool.cibuildwheel] -skip = ["cp36-*", "cp37-*", "cp38-*", "*-win32"] -build-frontend = "build" +skip = ["pp*", "cp36-*", "cp37-*", "cp38-*", "*-win32", "*-win_arm64"] #, "*-musllinux*"] +build-frontend = { name = "build", args = ["-w","-n","-x"] } +before-build = "pip install numpy ninja meson meson-python" +build-verbosity = "3" + +# https://github.com/pdfo/pdfo +[[tool.cibuildwheel.overrides]] +select = "*-win_amd64" +environment = { PKG_CONFIG_PATH="c:/opt/64/lib/pkgconfig" } + +[tool.cibuildwheel.windows] +repair-wheel-command = "bash .github/tools/cibw_repair_wheel_command_windows.sh {wheel} {dest_dir}"