Skip to content

Commit 0eb645b

Browse files
Merge pull request #3 from IntelPython/transition-to-scikit-build
Transition from numpy.distutils to scikit-build
2 parents 417010a + 6e73a4c commit 0eb645b

34 files changed

+2203
-986
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @oleksandr-pavlyk @xaleryb @ekomarova

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/conda-package.yml

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
name: Conda package
2+
3+
on: push
4+
5+
env:
6+
PACKAGE_NAME: mkl_umath
7+
MODULE_NAME: mkl_umath
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python: ['3.10', '3.11', '3.12']
15+
steps:
16+
- uses: actions/[email protected]
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set pkgs_dirs
21+
run: |
22+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
23+
24+
- name: Cache conda packages
25+
uses: actions/cache@v4
26+
env:
27+
CACHE_NUMBER: 0 # Increase to reset cache
28+
with:
29+
path: ~/.conda/pkgs
30+
key:
31+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
32+
restore-keys: |
33+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
34+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
35+
36+
- name: Add conda to system path
37+
run: echo $CONDA/bin >> $GITHUB_PATH
38+
39+
- name: Install conda-build
40+
run: conda install conda-build
41+
42+
- name: Build conda package
43+
run: |
44+
CHANNELS="-c conda-forge -c https://software.repos.intel.com/python/conda --override-channels"
45+
VERSIONS="--python ${{ matrix.python }}"
46+
TEST="--no-test"
47+
echo "CONDA_BLD=${CONDA}/conda-bld/linux-64" >> $GITHUB_ENV
48+
49+
conda build \
50+
$TEST \
51+
$VERSIONS \
52+
$CHANNELS \
53+
conda-recipe-cf
54+
55+
- name: Upload artifact
56+
uses: actions/[email protected]
57+
with:
58+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
59+
path: ${{ env.CONDA_BLD }}/${{ env.PACKAGE_NAME }}-*.tar.bz2
60+
61+
test:
62+
needs: build
63+
runs-on: ${{ matrix.runner }}
64+
65+
strategy:
66+
matrix:
67+
python: ['3.10', '3.11', '3.12']
68+
experimental: [false]
69+
runner: [ubuntu-latest]
70+
continue-on-error: ${{ matrix.experimental }}
71+
env:
72+
CHANNELS: -c conda-forge -c https://software.repos.intel.com/python/conda --override-channels
73+
74+
steps:
75+
- name: Download artifact
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
79+
- name: Add conda to system path
80+
run: echo $CONDA/bin >> $GITHUB_PATH
81+
- name: Install conda-build
82+
run: conda install conda-build
83+
- name: Create conda channel
84+
run: |
85+
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
86+
mv ${PACKAGE_NAME}-*.tar.bz2 $GITHUB_WORKSPACE/channel/linux-64
87+
conda index $GITHUB_WORKSPACE/channel
88+
# Test channel
89+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
90+
91+
- name: Collect dependencies
92+
run: |
93+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
94+
conda create -n test_mkl_umath $PACKAGE_NAME python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile
95+
- name: Display lockfile
96+
run: cat lockfile
97+
98+
- name: Set pkgs_dirs
99+
run: |
100+
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
101+
102+
- name: Cache conda packages
103+
uses: actions/cache@v4
104+
env:
105+
CACHE_NUMBER: 0 # Increase to reset cache
106+
with:
107+
path: ~/.conda/pkgs
108+
key:
109+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
110+
restore-keys: |
111+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
112+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
113+
114+
- name: Install mkl_umath
115+
run: |
116+
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
117+
conda create -n test_mkl_umath python=${{ matrix.python }} $PACKAGE_NAME pytest $CHANNELS
118+
# Test installed packages
119+
conda list -n test_mkl_umath
120+
121+
- name: Run tests
122+
run: |
123+
source $CONDA/etc/profile.d/conda.sh
124+
conda activate test_mkl_umath
125+
python -c "import mkl_umath, numpy as np; mkl_umath.use_in_numpy(); np.sin(np.linspace(0, 1, num=10**6));"
126+
127+
build_windows:
128+
runs-on: windows-2019
129+
130+
strategy:
131+
matrix:
132+
python: ['3.10', '3.11', '3.12']
133+
env:
134+
conda-bld: C:\Miniconda\conda-bld\win-64\
135+
steps:
136+
- uses: actions/[email protected]
137+
with:
138+
fetch-depth: 0
139+
140+
- uses: conda-incubator/setup-miniconda@v3
141+
with:
142+
miniforge-variant: Miniforge3
143+
miniforge-version: latest
144+
activate-environment: build
145+
channels: conda-forge
146+
python-version: ${{ matrix.python }}
147+
148+
- name: Cache conda packages
149+
uses: actions/cache@v4
150+
env:
151+
CACHE_NUMBER: 3 # Increase to reset cache
152+
with:
153+
path: /home/runner/conda_pkgs_dir
154+
key:
155+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
156+
restore-keys: |
157+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
158+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
159+
160+
- name: Store conda paths as envs
161+
shell: bash -l {0}
162+
run: |
163+
echo "CONDA_BLD=$CONDA/conda-bld/win-64/" | tr "\\\\" '/' >> $GITHUB_ENV
164+
165+
- name: Install conda build
166+
run: |
167+
conda activate
168+
conda install -y conda-build
169+
conda list -n base
170+
171+
- name: Build conda package
172+
run: |
173+
conda activate
174+
conda build --no-test --python ${{ matrix.python }} -c conda-forge -c https://software.repos.intel.com/python/conda --override-channels conda-recipe-cf
175+
176+
- name: Upload artifact
177+
uses: actions/[email protected]
178+
with:
179+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
180+
path: ${{ env.CONDA_BLD }}${{ env.PACKAGE_NAME }}-*.tar.bz2
181+
182+
test_windows:
183+
needs: build_windows
184+
runs-on: ${{ matrix.runner }}
185+
defaults:
186+
run:
187+
shell: cmd /C CALL {0}
188+
strategy:
189+
matrix:
190+
python: ['3.10', '3.11', '3.12']
191+
experimental: [false]
192+
runner: [windows-2019]
193+
continue-on-error: ${{ matrix.experimental }}
194+
env:
195+
workdir: '${{ github.workspace }}'
196+
CHANNELS: -c conda-forge -c https://software.repos.intel.com/python/conda --override-channels
197+
198+
steps:
199+
- name: Download artifact
200+
uses: actions/download-artifact@v4
201+
with:
202+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
203+
204+
- uses: conda-incubator/setup-miniconda@v3
205+
with:
206+
auto-update-conda: true
207+
conda-build-version: '*'
208+
miniforge-variant: Miniforge3
209+
miniforge-version: latest
210+
activate-environment: mkl_umath_test
211+
channels: conda-forge
212+
python-version: ${{ matrix.python }}
213+
214+
- name: Create conda channel with the artifact bit
215+
shell: cmd /C CALL {0}
216+
run: |
217+
echo ${{ env.workdir }}
218+
mkdir ${{ env.workdir }}\channel\win-64
219+
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
220+
dir ${{ env.workdir }}\channel\win-64
221+
222+
- name: Index the channel
223+
shell: cmd /C CALL {0}
224+
run: |
225+
conda index ${{ env.workdir }}\channel
226+
227+
- name: Dump mkl_umath version info from created channel to STDOUT
228+
shell: cmd /C CALL {0}
229+
run: |
230+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json
231+
- name: Dump mkl_umath version info from created channel into ver.json
232+
shell: cmd /C CALL {0}
233+
run: |
234+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
235+
- name: Output content of workdir
236+
shell: pwsh
237+
run: Get-ChildItem -Path ${{ env.workdir }}
238+
- name: Output content of produced ver.json
239+
shell: pwsh
240+
run: Get-Content -Path ${{ env.workdir }}\ver.json
241+
- name: Collect dependencies
242+
shell: cmd /C CALL {0}
243+
run: |
244+
IF NOT EXIST ver.json (
245+
copy /Y ${{ env.workdir }}\ver.json .
246+
)
247+
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
248+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
249+
SET PACKAGE_VERSION=%%F
250+
)
251+
conda install -n mkl_umath_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
252+
- name: Display lockfile content
253+
shell: pwsh
254+
run: Get-Content -Path .\lockfile
255+
- name: Cache conda packages
256+
uses: actions/cache@v4
257+
env:
258+
CACHE_NUMBER: 0 # Increase to reset cache
259+
with:
260+
path: /home/runner/conda_pkgs_dir
261+
key:
262+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
263+
restore-keys: |
264+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
265+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
266+
- name: Install mkl_umath
267+
shell: cmd /C CALL {0}
268+
run: |
269+
@ECHO ON
270+
IF NOT EXIST ver.json (
271+
copy /Y ${{ env.workdir }}\ver.json .
272+
)
273+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
274+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
275+
SET PACKAGE_VERSION=%%F
276+
)
277+
SET "TEST_DEPENDENCIES=pytest pytest-cov"
278+
conda install -n mkl_umath_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
279+
- name: Report content of test environment
280+
shell: cmd /C CALL {0}
281+
run: |
282+
conda activate
283+
echo "Value of CONDA enviroment variable was: " %CONDA%
284+
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
285+
conda info && conda list -n mkl_umath_test
286+
- name: Run tests
287+
shell: cmd /C CALL {0}
288+
run: >-
289+
conda activate mkl_umath_test && python -c "import mkl_umath, numpy as np; mkl_umath.use_in_numpy(); np.sin(np.linspace(0, 1, num=10**6));"
290+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '28 2 * * 1'
14+
- cron: '28 2 * * 4'
15+
push:
16+
branches: [ "master" ]
17+
18+
# Declare default permissions as read only.
19+
permissions: read-all
20+
21+
jobs:
22+
analysis:
23+
name: Scorecard analysis
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 30
26+
permissions:
27+
# Needed to upload the results to code-scanning dashboard.
28+
security-events: write
29+
# Needed to publish results and get a badge (see publish_results below).
30+
id-token: write
31+
# Uncomment the permissions below if installing in a private repository.
32+
# contents: read
33+
# actions: read
34+
35+
steps:
36+
- name: "Checkout code"
37+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
38+
with:
39+
persist-credentials: false
40+
41+
- name: "Run analysis"
42+
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
43+
with:
44+
results_file: results.sarif
45+
results_format: sarif
46+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
47+
# - you want to enable the Branch-Protection check on a *public* repository, or
48+
# - you are installing Scorecard on a *private* repository
49+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
50+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
51+
52+
# Public repositories:
53+
# - Publish results to OpenSSF REST API for easy access by consumers
54+
# - Allows the repository to include the Scorecard badge.
55+
# - See https://github.com/ossf/scorecard-action#publishing-results.
56+
# For private repositories:
57+
# - `publish_results` will always be set to `false`, regardless
58+
# of the value entered here.
59+
publish_results: true
60+
61+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
62+
# format to the repository Actions tab.
63+
- name: "Upload artifact"
64+
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
65+
with:
66+
name: SARIF file
67+
path: results.sarif
68+
retention-days: 14
69+
70+
# Upload the results to GitHub's code scanning dashboard.
71+
- name: "Upload to code-scanning"
72+
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
73+
with:
74+
sarif_file: results.sarif

0 commit comments

Comments
 (0)