diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0f3c5977..7c0ccc7e 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -102,12 +102,16 @@ jobs: github.event_name != 'workflow_dispatch' || github.event.inputs.run_build_bdist == 'true' + defaults: + run: + shell: bash -el {0} + steps: - # HACK: GitHub (macOS) runner image version (for deployment target). - - name: Extract (macOS) runner image version - run: >- - echo "IMAGE_VERSION=$(sw_vers --productVersion | cut -d '.' -f 1).0" - >> $GITHUB_ENV + # # HACK: GitHub (macOS) runner image version (for deployment target). + # - name: Extract (macOS) runner image version + # run: >- + # echo "IMAGE_VERSION=$(sw_vers --productVersion | cut -d '.' -f 1).0" + # >> $GITHUB_ENV # HACK: GitHub macOS runner defaults to a broken release of Xcode. # See https://github.com/actions/runner-images/issues/9273. @@ -120,13 +124,33 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up Python 3 - uses: actions/setup-python@v5 + # - name: Set up Python 3 + # uses: actions/setup-python@v5 + # with: + # python-version: '3.x' + + - name: Set up (Mini)conda + uses: conda-incubator/setup-miniconda@v3 with: - python-version: '3.x' + activate-environment: cibw + channels: conda-forge + channel-priority: strict + + # - name: Install packaging requirements + # run: python -m pip install --upgrade twine - name: Install packaging requirements - run: python -m pip install --upgrade twine + run: | + conda install -y twine + # Manage dependencies with Conda packages. + conda install -y cxx-compiler + conda install -y gsl fftw llvm-openmp + # Export Conda path. + conda_root=$(conda config --show root_prefix | sed 's/root_prefix: //') + echo "CONDA_ENV=${conda_root}/envs/cibw" >> $GITHUB_ENV + echo "CXX=${conda_root}/envs/cibw/bin/${CXX}" >> $GITHUB_ENV + echo "CXXFLAGS=${CXXFLAGS}" >> $GITHUB_ENV + echo "LDFLAGS=${LDFLAGS}" >> $GITHUB_ENV - name: Build built distribution uses: pypa/cibuildwheel@v2.18.1 @@ -135,19 +159,15 @@ jobs: output-dir: dist/ config-file: pyproject.toml env: - # Default to GCC compiler and OpenMP on macOS. - # HACK: Hardcode g++ compiler choice on GitHub macOS runners - # due to unusual Homebrew paths. In the CIBW workflow, Homebrew - # 'fftw' formula installs g++-14 as a dependency which conflicts - # with the runner image. - CIBW_ENVIRONMENT_MACOS: >- - PY_CXX=$(brew --prefix)/bin/g++-14 - PY_CXXFLAGS=-I$(brew --prefix)/include - PY_LDFLAGS=-L$(brew --prefix)/lib - # HACK: Hardcode macOS deployment target to align with the - # GitHub runner image version. In the CIBW workflow, - # Homebrew-installed libraries and `delocate-wheel` enforce this. - MACOSX_DEPLOYMENT_TARGET: ${{ env.IMAGE_VERSION }} + # # Default to GCC compiler and OpenMP on macOS. + # # HACK: Hardcode g++ compiler choice on GitHub macOS runners + # # due to unusual Homebrew paths. In the CIBW workflow, Homebrew + # # 'fftw' formula installs g++-14 as a dependency which conflicts + # # with the runner image. + # CIBW_ENVIRONMENT_MACOS: >- + # PY_CXX=$(brew --prefix)/bin/g++-14 + # PY_CXXFLAGS=-I$(brew --prefix)/include + # PY_LDFLAGS=-L$(brew --prefix)/lib # # Switch to LLVM compiler and OpenMP on macOS. # CIBW_ENVIRONMENT_MACOS: >- # PY_CXX=$(brew --prefix llvm@15)/bin/clang++ @@ -156,6 +176,27 @@ jobs: # PY_OMP=1 # PY_CXXFLAGS_OMP="-I$(brew --prefix libomp)/include -fopenmp" # PY_LDFLAGS_OMP="-L$(brew --prefix libomp)/lib -lomp" + # # HACK: Hardcode macOS deployment target to align with the + # # GitHub runner image version. In the CIBW workflow, + # # Homebrew-installed libraries and `delocate-wheel` enforce this. + # MACOSX_DEPLOYMENT_TARGET: ${{ env.IMAGE_VERSION }} + # Switch to Conda environment for dependencies. + # HACK: Hardcode g++ compiler choice on GitHub macOS runners + # due to unusual Homebrew paths. + CIBW_ENVIRONMENT_MACOS: >- + PY_CXX=${{ env.CXX }} + PY_CXXFLAGS="${{ env.CXXFLAGS }} -I$(brew --prefix)/include" + PY_LDFLAGS="${{ env.LDFLAGS }}" + PY_OMP=1 + PY_BUILD_PARALLEL='-j' + MACOSX_DEPLOYMENT_TARGET=11.0 + SYSTEM_VERSION_COMPAT=0 + MACOSX_DEPLOYMENT_TARGET: "11.0" + SYSTEM_VERSION_COMPAT: '0' + CIBW_BEFORE_ALL_MACOS: + CIBW_REPAIR_WHEEL_COMMAND_MACOS: | + delocate-listdeps {wheel} + delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} - name: Verify built distribution run: python -m twine check --strict dist/*