diff --git a/.github/workflows/_build-non-pure-package.yml b/.github/workflows/_build-non-pure-package.yml new file mode 100644 index 0000000..df5d8da --- /dev/null +++ b/.github/workflows/_build-non-pure-package.yml @@ -0,0 +1,147 @@ +name: Build wheel and sdist for a non-pure Python package + +on: + workflow_call: + +jobs: + build_sdist: + defaults: + run: + shell: bash -l {0} + + name: Build sdist + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: sdist + channels: conda-forge + auto-update-conda: true + auto-activate-base: false + python-version: 3.13 + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Build sdist + run: | + pip install --upgrade build + python -m build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: ./dist/*.tar.gz + + build-wheels: + needs: [build_sdist] + defaults: + run: + shell: bash -l {0} + + name: cibw-wheels-${{ matrix.python }}-${{ matrix.buildplat }} + runs-on: ${{ matrix.buildplat }} + strategy: + fail-fast: false + matrix: + buildplat: + - ubuntu-latest + - macos-13 + - macos-14 + - windows-latest + python: + - "3.11" + - "3.12" + - "3.13" + + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: build + channels: conda-forge + auto-update-conda: true + auto-activate-base: false + python-version: ${{ matrix.python }} + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install requirements + run: | + conda install --file requirements/conda.txt + conda install --file requirements/pip.txt + pip install --upgrade build + python -m pip wheel --no-deps --wheel-dir ./dist . + + - name: Upload wheels to GitHub + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.python }}-${{ matrix.buildplat }}.whl + path: ./dist/*.whl + + test-wheels: + needs: [build-wheels] + defaults: + run: + shell: bash -l {0} + + name: test-wheels-${{ matrix.python }}-${{ matrix.buildplat }} + runs-on: ${{ matrix.buildplat }} + strategy: + fail-fast: false + matrix: + buildplat: + - ubuntu-latest + - macos-13 + - macos-14 + - windows-latest + python: + - "3.11" + - "3.12" + - "3.13" + + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Download wheels + uses: actions/download-artifact@v4 + with: + name: ${{ matrix.python }}-${{ matrix.buildplat }}.whl + path: ./dist + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + channels: conda-forge + auto-update-conda: true + auto-activate-base: false + python-version: ${{ matrix.python }} + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install requirements + run: | + conda install --file requirements/conda.txt + conda install --file requirements/tests.txt + + - name: Install wheel and test + run: | + pip install ./dist/*.whl + pytest diff --git a/.github/workflows/_build-pdffit2-package.yml b/.github/workflows/_build-pdffit2-package.yml deleted file mode 100644 index e2a6702..0000000 --- a/.github/workflows/_build-pdffit2-package.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Build wheel and sdist for a non-pure Python package - -on: - workflow_call: - -jobs: - build_sdist: - name: Build diffpy.pdffit2 sdist - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v4 - with: - name: cibw-sdist - path: ./dist/*.tar.gz - - build-wheels: - needs: [build_sdist] - defaults: - run: - shell: bash -l {0} - - name: cibw-wheels-${{ matrix.python[0] }}-${{ matrix.buildplat[0] }} - runs-on: ${{ matrix.buildplat[0] }} - strategy: - fail-fast: false - matrix: - buildplat: - - [ubuntu-latest, manylinux_x86_64] - - [macos-13, macosx_x86_64] - - [macos-14, macosx_arm64] - - [windows-latest, win_amd64] - python: - - ["3.11", "cp311"] - - ["3.12", "cp312"] - - ["3.13", "cp313"] - - steps: - - name: Check out ${{ inputs.project }} - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python[0] }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python[0] }} - - - name: Linux build wheels - if: runner.os == 'Linux' - uses: pypa/cibuildwheel@v2.21.1 - env: - CIBW_BUILD: ${{ matrix.python[1] }}-${{ matrix.buildplat[1] }} - CIBW_BEFORE_BUILD: yum install -y gsl-devel && pip install -e . - with: - output-dir: dist - - - name: macOS build wheels - if: runner.os == 'macOS' - uses: pypa/cibuildwheel@v2.21.1 - env: - CIBW_BUILD: ${{ matrix.python[1] }}-${{ matrix.buildplat[1] }} - MACOSX_DEPLOYMENT_TARGET: 13.0 - CIBW_BEFORE_BUILD: brew install gsl && pip install -e . - with: - output-dir: dist - - - name: Windows setup conda environment - if: runner.os == 'Windows' - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: gsl - channels: conda-forge - auto-update-conda: true - auto-activate-base: false - - - name: Windows install gsl - if: runner.os == 'Windows' - run: | - conda config --set always_yes yes --set changeps1 no - conda install gsl - - - name: Windows build wheels - if: runner.os == 'Windows' - uses: pypa/cibuildwheel@v2.21.1 - env: - CIBW_BUILD: ${{ matrix.python[1] }}-${{ matrix.buildplat[1] }} - CONDA_PREFIX: ${{ env.CONDA_PREFIX }} - with: - output-dir: dist - - - name: Upload wheels to GitHub - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.python[0] }}-${{ matrix.buildplat[0] }}.whl - path: ./dist/*.whl diff --git a/.github/workflows/_build-wheel-release-upload.yml b/.github/workflows/_build-wheel-release-upload.yml index 9aa3ab9..ddc541d 100644 --- a/.github/workflows/_build-wheel-release-upload.yml +++ b/.github/workflows/_build-wheel-release-upload.yml @@ -38,8 +38,8 @@ jobs: build-non-pure-python-package: needs: [tag-privilege-check] - if: inputs.project == 'diffpy.pdffit2' || inputs.project == 'diffpy.srreal' || inputs.project == 'pyobjcryst' - uses: ./.github/workflows/_build-pdffit2-package.yml + if: inputs.c_extension + uses: ./.github/workflows/_build-non-pure-package.yml update-changelog: # The always() function is necessary to ensure that we wait for both build jobs to complete, even if one of them is skipped.