Skip to content

Commit 0d51ffd

Browse files
committed
Refactor project for PyPI distribution and wheel packaging
[pyomp] - Move to a src layout - Remove dependency on LLVM binaries in pyomp - Add versioning - Try-except without error for CUDALegalization (removed in recent numba) for CUDA lowering - Remove deprecated compile_isolated usage and update tests - Remove static libnrt building to avoid numba version dependency and use trampolines to link numba symbols to openmp target cpu modules - Add hello world examples - Update README [ci] - Create pypi workflow - Add test pipelines for multiple platforms, numba, and python versions - Simplify conda pipeline [openmp libraries] - Build openmp libraries through setup.py using LLVM static libraries from conda env - Add patches for missing includes and link statically with LLVM libs [pyomp pass] - Export entry point function to interface with python for running the pass - Link pass plugin with LLVM static libraries from conda env [packaging] - Extend range of supported numba (0.57-0.60) and python versions (3.9-3.12) - Make target offloading mandatory in tests - Remove building the static library in setup.py [packaging.wheel] - Add cibuildwheel scripts - Add MANIFEST.in - Add license files - Upload pre-release to testpypi, full release to pyp - Build and publish sdist [packaging.conda] - Remove llvm-openmp-dev recipe - Add missing deps in meta.yaml - Upload as a separate command to detect errors - Use "main" tag for full release for conda packages, "test" for pre-release, "dev" for PR [container] - Update dockerfile to avoid TOS issues - Add pyomp's version to the container
1 parent dd2825b commit 0d51ffd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1529
-913
lines changed

.github/workflows/build-containers.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ jobs:
99
steps:
1010
- name: Set up QEMU
1111
uses: docker/setup-qemu-action@v3
12-
12+
1313
- name: Set up Docker Buildx
1414
uses: docker/setup-buildx-action@v3
15-
15+
1616
- name: Login to GitHub Container Registry
1717
uses: docker/login-action@v3
1818
with:
1919
registry: ghcr.io
2020
username: ${{ github.actor }}
2121
password: ${{ secrets.GITHUB_TOKEN }}
22-
22+
2323
- name: Build and push pyomp container
2424
uses: docker/build-push-action@v6
2525
with:
2626
platforms: linux/amd64,linux/arm64
2727
file: buildscripts/containers/Dockerfile
2828
push: true
2929
provenance: false
30-
tags: ghcr.io/python-for-hpc/pyomp:latest
30+
tags: |
31+
ghcr.io/python-for-hpc/pyomp:latest
32+
ghcr.io/python-for-hpc/pyomp:${{ github.event.release.tag_name }}

.github/workflows/build-upload-conda-base.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/build-upload-conda-test.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,81 @@
1-
name: Deploy conda pkgs (main)
1+
name: conda
22

33
on:
44
release:
55
types: [published]
6+
pull_request:
7+
paths:
8+
- "buildscripts/conda-recipes/**"
9+
- ".github/workflows/build-upload-conda.yml"
10+
- "src/**"
11+
- setup.py
12+
- MANIFEST.in
13+
- pyproject.toml
614
workflow_dispatch:
715

816
jobs:
17+
# Job to deploy pyomp conda matrixed on os and python version.
918
deploy-conda:
10-
uses: ./.github/workflows/build-upload-conda-base.yml
11-
with:
12-
label: main
13-
env: .github/workflows/envs/env.yml
14-
secrets: inherit
19+
name: ${{ matrix.os }} ${{ matrix.python-version }}
20+
runs-on: ${{ matrix.os }}
21+
env:
22+
CONDA_LABEL: dev
23+
strategy:
24+
matrix:
25+
# TODO: Add windows.
26+
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
27+
python-version: ["3.9", "3.10", "3.11", "3.12"]
28+
steps:
29+
- name: Determine conda label
30+
run: |
31+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
32+
echo "CONDA_LABEL=dev" >> $GITHUB_ENV
33+
elif [[ "${{ github.event_name }}" == "release" && "${{ github.event.release.prerelease }}" == "true" ]]; then
34+
echo "CONDA_LABEL=test" >> $GITHUB_ENV
35+
else
36+
echo "CONDA_LABEL=main" >> $GITHUB_ENV
37+
fi
38+
39+
- uses: actions/checkout@v4
40+
# Checkout the repo with history to get the commit hash for the build
41+
# string.
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Create and activate conda env
46+
uses: conda-incubator/setup-miniconda@v3
47+
with:
48+
python-version: "3.10"
49+
auto-update-conda: false
50+
show-channel-urls: true
51+
52+
- name: Build and upload pyomp
53+
# This ensures conda env is active.
54+
shell: bash -l {0}
55+
run: |
56+
# Setup the anaconda environment.
57+
conda remove --name base conda-anaconda-telemetry
58+
conda install -q -y -c conda-forge conda-build conda-verify anaconda-client
59+
conda config --set anaconda_upload no
60+
61+
# Build the package.
62+
conda build \
63+
-c conda-forge \
64+
--python ${{ matrix.python-version }} \
65+
buildscripts/conda-recipes/pyomp
66+
67+
# Get the output file path.
68+
OUTPUT=$(conda build -c conda-forge --output \
69+
--python ${{ matrix.python-version }} \
70+
buildscripts/conda-recipes/pyomp)
71+
72+
# Upload the package.
73+
anaconda -t ${{ secrets.ANACONDA_TOKEN }} upload \
74+
--user python-for-hpc --label ${{ env.CONDA_LABEL}} \
75+
--force "$OUTPUT"
76+
1577
deploy-containers:
1678
needs: deploy-conda
79+
if: github.event_name == 'release' && !github.event.release.prerelease
1780
uses: ./.github/workflows/build-containers.yml
1881
secrets: inherit
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
name: pypi
2+
3+
on:
4+
release:
5+
types: [published]
6+
pull_request:
7+
paths:
8+
- "buildscripts/cibuildwheel/**"
9+
- ".github/workflows/build-upload-wheels.yml"
10+
- "src/**"
11+
- setup.py
12+
- MANIFEST.in
13+
- pyproject.toml
14+
workflow_dispatch:
15+
16+
jobs:
17+
# Always runs: Build wheels for all platforms and upload artifacts.
18+
build-wheels:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
# TODO: Add windows.
23+
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
24+
steps:
25+
- uses: actions/checkout@v4
26+
# Checkout the repo with history to get the commit hash for the build
27+
# string.
28+
with:
29+
fetch-depth: 0
30+
31+
# Used to host cibuildwheel.
32+
- uses: actions/setup-python@v5
33+
34+
- name: Install cibuildwheel
35+
run: python -m pip install cibuildwheel==3.1.4
36+
37+
- name: Build wheels
38+
run: python -m cibuildwheel --output-dir wheelhouse
39+
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
43+
path: ./wheelhouse/*.whl
44+
45+
build-sdist:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Build sdist
53+
run: pipx run build --sdist
54+
55+
- uses: actions/upload-artifact@v4
56+
with:
57+
name: cibw-sdist
58+
path: dist/*.tar.gz
59+
60+
# Always runs: Test wheels across OS/Python/Numba matrix.
61+
test-wheels:
62+
needs: build-wheels
63+
runs-on: ${{ matrix.os }}
64+
strategy:
65+
matrix:
66+
os: [ubuntu-latest, macos-latest, ubuntu-24.04-arm]
67+
python-version: ['3.9', '3.10', '3.11', '3.12']
68+
numba-version: ['0.57.0', '0.57.1', '0.58.0', '0.58.1', '0.59.0', '0.59.1', '0.60.0']
69+
exclude:
70+
# Known incompatibilities based on numba's official support
71+
# Numba 0.57 supports Python 3.8-3.11
72+
- python-version: '3.12'
73+
numba-version: '0.57.0'
74+
- python-version: '3.12'
75+
numba-version: '0.57.1'
76+
77+
# Numba 0.58 supports Python 3.8-3.11
78+
- python-version: '3.12'
79+
numba-version: '0.58.0'
80+
- python-version: '3.12'
81+
numba-version: '0.58.1'
82+
steps:
83+
- name: Download built wheels
84+
uses: actions/download-artifact@v5
85+
with:
86+
pattern: cibw-*
87+
path: dist
88+
merge-multiple: true
89+
90+
- name: Setup Python
91+
uses: actions/setup-python@v5
92+
with:
93+
python-version: ${{ matrix.python-version }}
94+
95+
- name: Install and test wheel
96+
run: |
97+
python -m pip install --upgrade pip
98+
python -m pip install "numba==${{ matrix.numba-version }}" lark cffi setuptools
99+
python -m pip install --pre --no-deps --no-index --find-links dist/ pyomp
100+
101+
# Verify the numba version.
102+
python -c "import numba; assert numba.__version__ == '${{ matrix.numba-version }}'"
103+
104+
# Run host OpenMP tests.
105+
TEST_DEVICES=0 RUN_TARGET=0 python -m numba.runtests -v -- numba.openmp.tests.test_openmp
106+
107+
# Run device (cpu target) OpenMP tests.
108+
OMP_TARGET_OFFLOAD=mandatory TEST_DEVICES=1 RUN_TARGET=1 \
109+
python -m numba.runtests -v -- numba.openmp.tests.test_openmp.TestOpenmpTarget
110+
111+
# Only on pre-release: Publish to TestPyPI for testing.
112+
publish-testpypi:
113+
needs: [build-wheels, test-wheels, build-sdist]
114+
if: github.event.release.prerelease
115+
runs-on: ubuntu-latest
116+
environment: testpypi
117+
permissions:
118+
id-token: write
119+
steps:
120+
- uses: actions/download-artifact@v5
121+
with:
122+
pattern: cibw-*
123+
path: dist
124+
merge-multiple: true
125+
126+
- name: Publish testpypi
127+
uses: pypa/gh-action-pypi-publish@release/v1
128+
with:
129+
repository-url: https://test.pypi.org/legacy/
130+
verbose: true
131+
132+
# Only on full release: Publish to production PyPI.
133+
publish-pypi:
134+
needs: [build-wheels, test-wheels, build-sdist]
135+
if: github.event_name == 'release' && !github.event.release.prerelease
136+
runs-on: ubuntu-latest
137+
environment: pypi
138+
permissions:
139+
id-token: write
140+
steps:
141+
- uses: actions/download-artifact@v5
142+
with:
143+
pattern: cibw-*
144+
path: dist
145+
merge-multiple: true
146+
147+
- name: Publish pypi
148+
uses: pypa/gh-action-pypi-publish@release/v1
149+
with:
150+
verbose: true

.github/workflows/envs/env-test.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/envs/env.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)