Wheels #197
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
name: Wheels | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
env: | |
GEANT4_GIT_TAG: v11.3.0 | |
GEANT4_SOURCE_DIR: geant4_source | |
GEANT4_BUILD_DIR: geant4_build | |
GEANT4_INSTALL_DIR: geant4_install | |
XERCES_C_GIT_REF: 53c0401812bfe5523594c1180f5ac7c758a2eaf7 | |
XERCES_C_SOURCE_DIR: xerces-c_source | |
XERCES_C_BUILD_DIR: xerces-c_build | |
XERCES_C_INSTALL_DIR: xerces-c_install | |
jobs: | |
build_sdist: | |
name: Build SDist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Build SDist | |
run: python setup.py sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: dist/*.tar.gz | |
name: sdist | |
build_wheels: | |
name: ${{ matrix.config.os }} ${{ matrix.config.arch }} - ${{ matrix.config.build-pattern }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
[ | |
{ os: windows-latest, arch: AMD64, build-pattern: cp* }, | |
{ os: windows-latest, arch: AMD64, build-pattern: pp* }, | |
{ os: macos-latest, arch: x86_64, build-pattern: cp* }, | |
{ os: macos-latest, arch: x86_64, build-pattern: pp* }, | |
{ os: macos-latest, arch: arm64, build-pattern: cp* }, | |
{ os: ubuntu-latest, arch: x86_64, build-pattern: cp*-manylinux* }, | |
{ os: ubuntu-latest, arch: x86_64, build-pattern: pp*-manylinux* }, | |
{ os: ubuntu-latest, arch: x86_64, build-pattern: cp*-musllinux* }, | |
] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Cache xerces-c install | |
uses: actions/cache@v4 | |
if: runner.os == 'Windows' | |
id: xerces-cache | |
with: | |
path: ${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }} | |
key: ${{ env.XERCES_C_GIT_REF }} | |
- name: Cache Geant4 install | |
uses: actions/cache@v4 | |
if: runner.os == 'Windows' | |
id: g4cache | |
with: | |
path: ${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }} | |
key: ${{ env.GEANT4_GIT_TAG }}-${{ env.XERCES_C_GIT_REF }} | |
- uses: actions/checkout@v4 | |
if: runner.os == 'Windows' && steps.xerces-cache.outputs.cache-hit != 'true' | |
with: | |
repository: apache/xerces-c | |
ref: ${{ env.XERCES_C_GIT_REF }} | |
path: ${{ env.XERCES_C_SOURCE_DIR }} | |
- uses: lukka/get-cmake@latest | |
if: runner.os == 'Windows' && (steps.g4cache.outputs.cache-hit != 'true' || steps.xerces-cache.outputs.cache-hit != 'true') | |
- name: CMake build xerces-c Windows | |
if: runner.os == 'Windows' && steps.xerces-cache.outputs.cache-hit != 'true' | |
run: > | |
cmake | |
-DBUILD_SHARED_LIBS=OFF | |
-DCMAKE_CXX_FLAGS_RELEASE="/MT" | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.XERCES_C_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" && | |
cmake --build "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" --config Release && | |
cmake --build "${{ github.workspace }}/${{ env.XERCES_C_BUILD_DIR }}" --config Release --target install | |
- uses: actions/checkout@v4 | |
if: runner.os == 'Windows' && steps.g4cache.outputs.cache-hit != 'true' | |
with: | |
repository: Geant4/geant4 | |
ref: ${{ env.GEANT4_GIT_TAG }} | |
path: ${{ env.GEANT4_SOURCE_DIR }} | |
- name: CMake build Geant4 Windows | |
if: runner.os == 'Windows' && steps.g4cache.outputs.cache-hit != 'true' | |
run: > | |
cmake | |
-DBUILD_STATIC_LIBS=ON | |
-DBUILD_SHARED_LIBS=OFF | |
-DGEANT4_INSTALL_EXAMPLES=OFF | |
-DGEANT4_USE_GDML=ON | |
-DGEANT4_BUILD_TLS_MODEL=global-dynamic | |
-DGEANT4_USE_OPENGL_WIN32=ON | |
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded | |
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}" | |
-S "${{ github.workspace }}/${{ env.GEANT4_SOURCE_DIR }}" | |
-B "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" && | |
cmake --build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" --config Release && | |
cmake --build "${{ github.workspace }}/${{ env.GEANT4_BUILD_DIR }}" --config Release --target install | |
- name: Setup environment variables | |
if: runner.os == 'Windows' | |
shell: bash | |
run: | | |
echo "${{ github.workspace }}/${{ env.GEANT4_INSTALL_DIR }}/bin" >> $GITHUB_PATH | |
echo "HOME=${{ github.workspace }}" >> $GITHUB_ENV | |
echo "CMAKE_ARGS=-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" >> $GITHUB_ENV | |
echo "CMAKE_PREFIX_PATH=${{ github.workspace }}/${{ env.XERCES_C_INSTALL_DIR }}" >> $GITHUB_ENV | |
- name: Extra Licenses | |
shell: bash | |
run: | | |
curl "https://raw.githubusercontent.com/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/LICENSE" > EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/clhep/COPYING.LESSER" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/expat/COPYING" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/g4tools/tools.license" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/ptl/LICENSE" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/apache/xerces-c/${{ env.XERCES_C_GIT_REF }}/NOTICE" >> EXTRA_LICENSES | |
echo -e "\n\n" >> EXTRA_LICENSES | |
curl "https://raw.githubusercontent.com/apache/xerces-c/${{ env.XERCES_C_GIT_REF }}/LICENSE" >> EXTRA_LICENSES | |
- name: Cache Geant4 datasets | |
if: runner.os != 'Linux' | |
uses: actions/cache@v4 | |
with: | |
key: ${{ env.GEANT4_GIT_TAG }}-datasets | |
path: ${{ github.workspace }}/.geant4_pybind | |
enableCrossOsArchive: true | |
- uses: pypa/cibuildwheel@v2.22.0 | |
env: | |
CIBW_ENVIRONMENT_LINUX: CXXFLAGS='-fPIC' CFLAGS='-fPIC' | |
CIBW_BEFORE_ALL_LINUX: > | |
python3 -m pip install cmake && | |
yum install -y libXt-devel libXmu-devel mesa-libGL-devel libxkbcommon-devel fontconfig-devel libcurl-devel || | |
apt-get install -y libxt-dev libxmu-dev libgl1-mesa-dev libxkbcommon-dev libfontconfig1-dev libcurl-dev || | |
apk add libxt-dev libxmu-dev mesa-dev libxkbcommon-dev fontconfig-dev curl-dev && | |
git clone https://github.com/apache/xerces-c | |
"{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
cd "{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
git checkout ${{ env.XERCES_C_GIT_REF }} && | |
mkdir "{package}/${{ env.XERCES_C_BUILD_DIR }}" && | |
cd "{package}/${{ env.XERCES_C_BUILD_DIR }}" && | |
cmake | |
-Dnetwork-accessor=curl | |
-Dtranscoder=iconv | |
-DBUILD_SHARED_LIBS=OFF | |
"{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
make -j8 && | |
make install && | |
echo -e "\n\n\nThis software contains parts of Qt5 | |
licensed under GPL-2.0, GPL-3.0 and LGPL-3.0. | |
\nLicense information and source code are available at: | |
https://github.com/qt/qt5 | |
\nFor information on how Qt5 was built please see: | |
https://github.com/HaarigerHarald/geant4_pybind/blob/main/.github/workflows/wheels.yml | |
\n\n" >> "{package}/EXTRA_LICENSES" && | |
git clone -b v5.14.2 --depth 1 https://github.com/qt/qt5 "{package}/qt5" && | |
cd "{package}/qt5" && | |
git submodule update --init --recursive --depth 1 qt3d qtbase && | |
sed -i '48 i # include <limits>' "{package}/qt5/qtbase/src/corelib/global/qglobal.h" && | |
${{ matrix.config.build-pattern == 'cp*-musllinux*' && 'echo "QMAKE_LIBS_EXECINFO = -lexecinfo" >> "{package}/qt5/qtbase/mkspecs/common/gcc-base.conf" &&' || '' }} | |
./configure -opensource -confirm-license -release -qt-zlib -qt-libjpeg -qt-libpng -fontconfig -system-freetype | |
-no-harfbuzz -qt-xcb -qt-pcre -skip qtwebengine -no-feature-sqlmodel -skip qtconnectivity -skip qtdoc | |
-nomake examples -nomake tools -nomake tests -static && | |
make -j8 && | |
make install && | |
echo -e "\nqt5_import_plugins(geant4_pybind | |
\n INCLUDE Qt5::QXcbIntegrationPlugin Qt5::QMinimalIntegrationPlugin Qt5::QLinuxFbIntegrationPlugin | |
\n INCLUDE_BY_TYPE imageformats Qt5::QPngPlugin Qt5::QGifPlugin Qt5::QJpegPlugin | |
\n EXCLUDE_BY_TYPE sqldrivers | |
\n)" >> "{package}/source/CMakeLists.txt" && | |
git clone -b ${{ env.GEANT4_GIT_TAG }} --depth 1 | |
https://github.com/Geant4/geant4 | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
mkdir "{package}/${{ env.GEANT4_BUILD_DIR }}" && | |
cd "{package}/${{ env.GEANT4_BUILD_DIR }}" && | |
cmake | |
-DCMAKE_BUILD_TYPE=Release | |
-DBUILD_STATIC_LIBS=ON | |
-DBUILD_SHARED_LIBS=OFF | |
-DGEANT4_INSTALL_EXAMPLES=OFF | |
-DGEANT4_USE_SYSTEM_EXPAT=OFF | |
-DGEANT4_USE_GDML=ON | |
-DGEANT4_BUILD_TLS_MODEL=global-dynamic | |
-DGEANT4_USE_QT=ON | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
make -j8 && | |
make install | |
CIBW_ENVIRONMENT_MACOS: > | |
CXXFLAGS='-fPIC' CFLAGS='-fPIC' MACOSX_DEPLOYMENT_TARGET=10.15 | |
${{ matrix.config.arch == 'arm64' && 'SKIP_PYBIND11_STUBGEN=1' || '' }} | |
CIBW_BEFORE_ALL_MACOS: > | |
brew install cmake && | |
git clone https://github.com/apache/xerces-c | |
"{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
cd "{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
git checkout ${{ env.XERCES_C_GIT_REF }} && | |
mkdir "{package}/${{ env.XERCES_C_BUILD_DIR }}" && | |
cd "{package}/${{ env.XERCES_C_BUILD_DIR }}" && | |
cmake | |
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} | |
-Dnetwork-accessor=curl | |
-Dtranscoder=iconv | |
-DBUILD_SHARED_LIBS=OFF | |
"{package}/${{ env.XERCES_C_SOURCE_DIR }}" && | |
make -j8 && | |
sudo make install && | |
echo -e "\n\n\nThis software contains parts of Qt5 | |
licensed under GPL-2.0, GPL-3.0 and LGPL-3.0. | |
\nLicense information and source code are available at: | |
https://github.com/qt/qt5 | |
\nFor information on how Qt5 was built please see: | |
https://github.com/HaarigerHarald/geant4_pybind/blob/main/.github/workflows/wheels.yml | |
\n\n" >> "{package}/EXTRA_LICENSES" && | |
git clone -b v5.15.11-lts-lgpl --depth 1 https://github.com/qt/qt5 "{package}/qt5" && | |
cd "{package}/qt5" && | |
git submodule update --init --recursive --depth 1 qt3d qtbase && | |
./configure -opensource -confirm-license -release -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype | |
-qt-harfbuzz -qt-pcre -skip qtwebengine -no-feature-sqlmodel -skip qtconnectivity -skip qtdoc | |
-nomake examples -nomake tools -nomake tests -static QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" && | |
make -j8 && | |
sudo make install && | |
git clone -b ${{ env.GEANT4_GIT_TAG }} --depth 1 | |
https://github.com/Geant4/geant4 | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
mkdir "{package}/${{ env.GEANT4_BUILD_DIR }}" && | |
cd "{package}/${{ env.GEANT4_BUILD_DIR }}" && | |
cmake | |
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.config.arch }} | |
-DCMAKE_BUILD_TYPE=Release | |
-DBUILD_STATIC_LIBS=ON | |
-DBUILD_SHARED_LIBS=OFF | |
-DGEANT4_INSTALL_EXAMPLES=OFF | |
-DGEANT4_USE_SYSTEM_EXPAT=OFF | |
-DGEANT4_USE_GDML=ON | |
-DGEANT4_BUILD_TLS_MODEL=global-dynamic | |
-DGEANT4_USE_QT=ON | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
make -j8 && | |
sudo make install | |
CIBW_ARCHS: ${{ matrix.config.arch }} | |
CIBW_BUILD: ${{ matrix.config.build-pattern }} | |
CIBW_BEFORE_BUILD: rm -rf {project}/build | |
CIBW_TEST_COMMAND_MACOS: HOME={package} python {package}/tests/test_B1.py | |
CIBW_TEST_COMMAND_WINDOWS: python {package}/tests/test_B1.py | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-${{ matrix.config.os }}-${{ strategy.job-index }} | |
path: wheelhouse/*.whl | |
upload_all: | |
name: Upload wheels | |
needs: [build_wheels, build_sdist] | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/setup-python@v5 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
merge-multiple: true | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |