diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..60b32646 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + #os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.23.2 + # env: + # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + make_sdist: + name: Make SDist + runs-on: ubuntu-latest + container: nvidia/cuda:12.8.1-devel-ubuntu24.04 + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v3 + with: + version: 0.6.9 + enable-cache: true + - name: Build SDist + run: uv build --sdist + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..8bbb0235 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ + name: Release + + on: + push: + tags: + # Publish on any tag starting with a `v`, e.g. v1.2.3 + - v* + + jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + #os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] + os: [ubuntu-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.23.2 + # env: + # CIBW_SOME_OPTION: value + # ... + # with: + # package-dir: . + # output-dir: wheelhouse + # config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + make_sdist: + name: Make SDist + runs-on: ubuntu-latest + container: nvidia/cuda:12.8.1-devel-ubuntu24.04 + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v3 + with: + version: 0.6.9 + enable-cache: true + - name: Build SDist + run: uv build --sdist + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + pypi: + name: Publish to PyPI + needs: [build_wheels, make_sdist] + runs-on: ubuntu-latest + # Environment and permissions trusted publishing. + environment: + # Create this environment in the GitHub repository under Settings -> Environments + name: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v3 + with: + version: 0.6.9 + enable-cache: true + - name: Get Pyproject Version + run: | + export PYPROJECT_VERSION=v$(uvx --from=toml-cli toml get --toml-path=pyproject.toml project.version) + echo "PYPROJECT_VERSION=$PYPROJECT_VERSION" >> "$GITHUB_ENV" + - name: Validate version with tag + if: ${{ github.ref_name != env.PYPROJECT_VERSION }} + uses: actions/github-script@v3 + with: + script: | + core.setFailed('Tag version ${{ github.ref_name }} does not match pyproject version ${{ env.PYPROJECT_VERSION }}') + - uses: actions/download-artifact@v4 + with: + pattern: cibw-* + path: dist + merge-multiple: true + - name: Publish wheel + run: uv publish --trusted-publishing always diff --git a/pyproject.toml b/pyproject.toml index 7376a9b1..e422f26a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,3 +46,21 @@ where = ["Python"] [tool.setuptools.package-data] "tigre.utilities.cuda_interface" = ["*.pyx", "*.pxd", "*.cpp"] +[tool.cibuildwheel] +build-frontend = "build[uv]" +skip = "pp* *musl*" +archs = ["native"] + +[tool.cibuildwheel.linux] +#CUDA Installation +before-all = """ +rpm --import https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/7fa2af80.pub && +yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && +yum clean all && +yum -y install cuda-nvcc-12-4 cuda-cudart-devel-12-4 libcurand-devel-12-4 && +ls -al /usr/local && +export PATH=$PATH:/usr/local/cuda/bin && +export CUDA_PATH=/usr/local/cuda && +nvcc --version && +export BUILD_WITH_CUDA=1 +"""