Skip to content

Commit

Permalink
copying pyproject.toml and github workflow from 2.7.5 python wheel br…
Browse files Browse the repository at this point in the history
…anch
  • Loading branch information
stephen-dixon committed May 8, 2024
1 parent 9a7c6a2 commit 280ec9c
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 8 deletions.
227 changes: 227 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
name: build and upload wheels

on:
push:
branches:
- feature/python-wheels

jobs:
build_wheels:
# name: build wheels on ${{matrix.os}} ${{matrix.arch}}
name: build wheels on ${{matrix.build-platform[0]}} ${{matrix.build-platform[1]}}
# runs-on: ${{matrix.os}}
runs-on: ${{matrix.build-platform[0]}}
strategy:
fail-fast: false
matrix:
build-platform:
## - [ubuntu-latest, x86_64, manylinux2014_x86_64]
#- [ubuntu-latest, x86_64, manylinux_2_28_x86_64]
## - [ubuntu-latest,aarch64,manylinux_2_28_aarch64]
#- [macos-13, x86_64, macosx_x86_64]
#- [macos-14, arm64, macosx_arm64]
- [windows-latest, AMD64, win_amd64]
# python:
# ["cp36", "cp37", "cp38", "cp39", "cp310", "cp311"]


steps:
- uses: actions/checkout@v3
# need git tags available for setuptools_scm to grab tags? will lead to slower checkout
with:
fetch-depth: 0

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all


- name: build uda on windows
if: runner.os == 'Windows'
run: >
vcpkg install --triplet x64-mingw-static --binarysource="clear;x-gha,readwrite"
libxml2
capnproto
boost-program-options
boost-format
boost-algorithm
boost-multi-array
openssl
dlfcn-win32
spdlog
&& cmake -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -B extlib/build -G "MinGW Makefiles" ./extlib
&& cmake --build extlib/build
&& cmake --install extlib/build --prefix extlib/install
&& XDR_ROOT=extlib/install cmake -G "MinGW Makefiles" -B build
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release
-DSSLAUTHENTICATION=OFF
-DCLIENT_ONLY=ON
-DENABLE_CAPNP=ON
-DCMAKE_INSTALL_PREFIX=$PWD/install
&& cmake --build build -j --config Release
&& cmake --install --prefix install --config Release
&& ls install/lib
- name: test pyuda on windows
if: runner.os == 'Windows'
run: >
cp -r /usr/local/python_installer ${{github.workspace}}/python_installer &&
python3 -m venv ${{github.workspace}}/venv &&
source ${{github.workspace}}/venv/bin/activate &&
pip3 install Cython numpy six &&
pip3 install install/python_installer
- name: build windows wheels
if: runner.OS == 'Windows'
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: ./source/wrappers/python
config-file: ./source/wrappers/python/pyproject.toml
env:
CIBW_ARCHS: ${{matrix.build-platform[1]}}
CIBW_PLATFORM: windows
CIBW_BUILD: cp*-${{matrix.build-platform[2]}}


- name: Build manylinux2014 wheels
if: startswith(matrix.build-platform[2], 'manylinux2014')
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: ./source/wrappers/python
config-file: ./source/wrappers/python/pyproject.toml
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_ARCHS: ${{matrix.build-platform[1]}}
CIBW_BUILD: cp*-manylinux*
CIBW_SKIP: *-musllinux*
CIBW_BEFORE_ALL: >
yum update -y &&
yum install -y wget openssl-devel libxml2-devel libtirpc-devel &&
cd /tmp &&
wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz &&
tar xzf 10.0.0.tar.gz &&
cd fmt-10.0.0 &&
cmake -Bbuild -H. -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON &&
cmake --build build -j --config Release --target install &&
cd /tmp &&
wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz &&
tar xzf v1.11.0.tar.gz &&
cd spdlog-1.11.0 &&
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON &&
cmake --build build -j --config Release --target install &&
cd /tmp &&
wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz &&
tar xzf v0.10.4.tar.gz &&
cd capnproto-0.10.4 &&
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON &&
cmake --build build &&
cmake --install build &&
cd /tmp &&
wget https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz &&
tar xzf boost_1_80_0.tar.gz &&
cd boost_1_80_0 &&
./bootstrap.sh --prefix=/usr/local &&
./b2 --without-python --prefix=/usr/local install &&
cd /project &&
cmake -B build -DNO_JAVA_WRAPPER=ON -DBUILD_SHARED_LIBS=ON -DSSLAUTHENTICATION=OFF -DENABLE_CAPNP=ON -DCLIENT_ONLY=ON &&
cmake --build build -j --config Release --target install &&
cp -r /usr/local/python_installer/* /project/source/wrappers/python/
- name: Build manylinux_2_28 wheels
if: startswith(matrix.build-platform[2], 'manylinux_2_28')
uses: pypa/cibuildwheel@v2.17.0
with:
# package-dir: /usr/local/python_installer
package-dir: ./source/wrappers/python
config-file: ./source/wrappers/python/pyproject.toml
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28
CIBW_ARCHS: ${{matrix.build-platform[1]}}
CIBW_BUILD: cp*-manylinux*
CIBW_SKIP: *-musllinux*
CIBW_BEFORE_ALL: >
dnf update -y &&
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm &&
dnf install -y boost-devel openssl-devel libxml2-devel libtirpc-devel
fmt fmt-devel spdlog spdlog-devel capnproto capnproto-devel &&
cd /project &&
cmake -B build
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release
-DSSLAUTHENTICATION=OFF
-DNO_JAVA_WRAPPER=ON
-DENABLE_CAPNP=ON -DCLIENT_ONLY=ON &&
cmake --build build -j --config Release --target install &&
cp -r /usr/local/python_installer/* /project/source/wrappers/python/
- name: build uda on macos
if: runner.os == 'macOS'
run: >
brew update-reset && brew install
git
boost
openssl
cmake
libxml2
spdlog
capnp &&
cd ${{github.workspace}} &&
cmake -B build
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release
-DSSLAUTHENTICATION=OFF
-DENABLE_CAPNP=ON
-DNO_JAVA_WRAPPER=ON
-DCMAKE_INSTALL_PREFIX=$PWD/install
-DCLIENT_ONLY=ON &&
cmake --build build -j --config Release --target install &&
cp -r $PWD/install/python_installer/* ${{github.workspace}}/source/wrappers/python/
- name: Build macos wheels
if: runner.os == 'macOS'
uses: pypa/cibuildwheel@v2.17.0
with:
package-dir: ./source/wrappers/python
config-file: ./source/wrappers/python/pyproject.toml
env:
CIBW_ARCHS: ${{matrix.build-platform[1]}}
CIBW_PLATFORM: macos
CIBW_BUILD: cp*-${{matrix.build-platform[2]}}
#CIBW_SKIP: cp36* cp37*
# CIBW_BEFORE_ALL:
# cat ./source/wrappers/python/setup.py

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

upload_pypi:
needs: build_wheels
runs-on: ubuntu-latest
environment:
name: testpypi
# url: https://test.pypi.org/project/ukaea_pyuda/
permissions:
id-token: write
# if: github.event_name == 'release' && github.event.action == 'published'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
17 changes: 17 additions & 0 deletions source/wrappers/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build-system]
requires = ["setuptools>=42", "numpy>=1.7", "Cython>=0.29", "six"]
build-backend = "setuptools.build_meta"


[project]
name = "ukaea_pyuda_test"
# version = "2.7.5"
dynamic = ["version"]
readme = {file = 'README.md', content-type = "text/markdown"}
license = {text = "Apache-2.0 license"}
dependencies = ["numpy", "six"]
requires-python = ">= 3.5"

[project.optional-dependencies]
plot = ["pyplot"]
full = ["pyplot", "rich"]
26 changes: 18 additions & 8 deletions source/wrappers/python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys
import sysconfig
from distutils.core import setup, Extension
from setuptools import setup, Extension
from Cython.Build import cythonize
from Cython.Compiler.Main import default_options
import numpy
Expand All @@ -28,6 +28,9 @@ elif sys.platform.lower() == 'darwin':
dynlib_ext = 'dylib'
# On Mac OS we have to force setting of rpath
extra_link_args.append('-Wl,-rpath,%s' % os.path.join(root, 'lib'))
else:
stalib_ext = 'a'
dynlib_ext = 'so'

uda_lib_names = '@UDA_LIBS@'.split(';') if '@UDA_LIBS@' else []
build_fat = os.environ.get('UDA_FAT_PYTHON', False)
Expand All @@ -47,7 +50,7 @@ else:

ext = Extension(
'cpyuda',
['pyuda/cpyuda/cpyuda.pyx'],
['ukaea_pyuda_test/cpyuda/cpyuda.pyx'],
include_dirs=list(filter(None, [
'/usr/include/tirpc',
'@TIRPC_PYUDA_INCLUDE_DIR@',
Expand Down Expand Up @@ -78,15 +81,22 @@ ext = Extension(
define_macros=extra_macros,
)


def get_version(v):
if v.count('.') > 2:
v = ".Post".join(v.rsplit('.', 1))
print("setup version = %s" % v)
return v


# use_scm_version={'version_scheme': 'post-release', 'local_scheme': 'no-local-version'},
setup(
name='@PROJECT_NAME@',
version='@PROJECT_VERSION@',
name='ukaea_pyuda_test',
version=get_version('@PROJECT_VERSION@'),
description='Unified Data Access (UDA)',
author='Jonathan Hollocombe',
author_email='jonathan.hollocombe@ukaea.uk',
url='https://github.com/ukaea/UDA',
packages=['pyuda'],
url='https://github.com/stephen-dixon/uda',
packages=['ukaea_pyuda_test'],
ext_modules=cythonize([ext]),
setup_requires=['numpy>=1.7', 'Cython>=0.29', 'six'],
install_requires=['numpy>=1.7', 'six'],
)

0 comments on commit 280ec9c

Please sign in to comment.