Skip to content

Commit 3ccabb6

Browse files
Merge pull request #88 from IntelPython/fixes-for-np-1.25
Adapt to NumPy 1.25
2 parents 7110797 + fc2a036 commit 3ccabb6

File tree

8 files changed

+154
-21
lines changed

8 files changed

+154
-21
lines changed

.github/workflows/conda-package.yml

Lines changed: 139 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ env:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python: [3.9]
14+
python: ['3.10']
1515
steps:
1616
- uses: actions/checkout@v3
1717
with:
@@ -38,7 +38,7 @@ jobs:
3838
run: conda install conda-build
3939
- name: Build conda package
4040
run: |
41-
CHANNELS="-c intel -c main --override-channels"
41+
CHANNELS="-c conda-forge -c intel --override-channels"
4242
VERSIONS="--python ${{ matrix.python }}"
4343
TEST="--no-test"
4444
@@ -59,9 +59,9 @@ jobs:
5959

6060
strategy:
6161
matrix:
62-
python: [3.9]
62+
python: ['3.10']
6363
experimental: [false]
64-
runner: [ubuntu-20.04]
64+
runner: [ubuntu-latest]
6565
continue-on-error: ${{ matrix.experimental }}
6666
env:
6767
CHANNELS: -c intel -c main --override-channels
@@ -115,3 +115,137 @@ jobs:
115115
source $CONDA/etc/profile.d/conda.sh
116116
conda activate test_mkl_fft
117117
pytest -v --pyargs $MODULE_NAME
118+
119+
build_windows:
120+
runs-on: windows-latest
121+
122+
strategy:
123+
matrix:
124+
python: ['3.10']
125+
env:
126+
conda-bld: C:\Miniconda\conda-bld\win-64\
127+
steps:
128+
- uses: actions/checkout@v3
129+
with:
130+
fetch-depth: 0
131+
- uses: conda-incubator/setup-miniconda@v2
132+
with:
133+
auto-activate-base: true
134+
conda-build-version: "*"
135+
activate-environment: true
136+
python-version: ${{ matrix.python }}
137+
138+
- name: Cache conda packages
139+
uses: actions/cache@v3
140+
env:
141+
CACHE_NUMBER: 3 # Increase to reset cache
142+
with:
143+
path: /home/runner/conda_pkgs_dir
144+
key:
145+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('**/meta.yaml') }}
146+
restore-keys: |
147+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
148+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
149+
- name: Build conda package
150+
run: conda build --no-test --python ${{ matrix.python }} -c intel -c conda-forge --override-channels conda-recipe
151+
- name: Upload artifact
152+
uses: actions/upload-artifact@v3
153+
with:
154+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
155+
path: ${{ env.conda-bld }}${{ env.PACKAGE_NAME }}-*.tar.bz2
156+
157+
test_windows:
158+
needs: build_windows
159+
runs-on: ${{ matrix.runner }}
160+
defaults:
161+
run:
162+
shell: cmd /C CALL {0}
163+
strategy:
164+
matrix:
165+
python: ['3.10']
166+
experimental: [false]
167+
runner: [windows-latest]
168+
continue-on-error: ${{ matrix.experimental }}
169+
env:
170+
workdir: '${{ github.workspace }}'
171+
CHANNELS: -c intel -c conda-forge --override-channels
172+
173+
steps:
174+
- name: Download artifact
175+
uses: actions/download-artifact@v3
176+
with:
177+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
178+
- uses: conda-incubator/setup-miniconda@v2
179+
with:
180+
auto-update-conda: true
181+
conda-build-version: '*'
182+
miniconda-version: 'latest'
183+
activate-environment: mkl_fft_test
184+
python-version: ${{ matrix.python }}
185+
- name: Create conda channel with the artifact bit
186+
shell: cmd /C CALL {0}
187+
run: |
188+
echo ${{ env.workdir }}
189+
mkdir ${{ env.workdir }}\channel\win-64
190+
move ${{ env.PACKAGE_NAME }}-*.tar.bz2 ${{ env.workdir }}\channel\win-64
191+
dir ${{ env.workdir }}\channel\win-64
192+
- name: Index the channel
193+
shell: cmd /C CALL {0}
194+
run: conda index ${{ env.workdir }}\channel
195+
196+
- name: Dump mkl_fft version info from created channel into ver.json
197+
shell: cmd /C CALL {0}
198+
run: |
199+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.workdir }}/channel --override-channels --info --json > ${{ env.workdir }}\ver.json
200+
- name: Output content of produced ver.json
201+
shell: pwsh
202+
run: Get-Content -Path ${{ env.workdir }}\ver.json
203+
- name: Collect dependencies
204+
shell: cmd /C CALL {0}
205+
run: |
206+
IF NOT EXIST ver.json (
207+
copy /Y ${{ env.workdir }}\ver.json .
208+
)
209+
SET "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
210+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
211+
SET PACKAGE_VERSION=%%F
212+
)
213+
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile
214+
- name: Display lockfile content
215+
shell: pwsh
216+
run: Get-Content -Path .\lockfile
217+
- name: Cache conda packages
218+
uses: actions/cache@v3
219+
env:
220+
CACHE_NUMBER: 0 # Increase to reset cache
221+
with:
222+
path: /home/runner/conda_pkgs_dir
223+
key:
224+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{hashFiles('lockfile') }}
225+
restore-keys: |
226+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-
227+
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
228+
- name: Install mkl_fft
229+
shell: cmd /C CALL {0}
230+
run: |
231+
@ECHO ON
232+
IF NOT EXIST ver.json (
233+
copy /Y ${{ env.workdir }}\ver.json .
234+
)
235+
set "SCRIPT=%VER_SCRIPT1% %VER_SCRIPT2%"
236+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
237+
SET PACKAGE_VERSION=%%F
238+
)
239+
SET "TEST_DEPENDENCIES=pytest pytest-cov"
240+
conda install -n mkl_fft_test ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
241+
- name: Report content of test environment
242+
shell: cmd /C CALL {0}
243+
run: |
244+
echo "Value of CONDA enviroment variable was: " %CONDA%
245+
echo "Value of CONDA_PREFIX enviroment variable was: " %CONDA_PREFIX%
246+
conda info && conda list -n mkl_fft_test
247+
- name: Run tests
248+
shell: cmd /C CALL {0}
249+
run: >-
250+
conda activate mkl_fft_test && python -m pytest -v -s --pyargs ${{ env.MODULE_NAME }}
251+

conda-recipe/bld.bat

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@rem Remember to activate Intel Compiler, or remoe these two lines to ise Microsoft Visual Studio compiler
2-
31
set MKLROOT=%PREFIX%
4-
%PYTHON% setup.py build --force install --old-and-unmanageable
2+
%PYTHON% -m pip install --no-build-isolation --no-deps .
53
if errorlevel 1 exit 1

conda-recipe/build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash -x
22

3-
# make sure that compiler has been sourced, if necessary
4-
53
if [ `uname` == Darwin ]; then
64
export MACOSX_DEPLOYMENT_TARGET=10.9
75
fi
86

9-
MKLROOT=$PREFIX CFLAGS="-I$PREFIX/include $CFLAGS" $PYTHON setup.py build --force install --old-and-unmanageable
7+
export MKLROOT=$PREFIX
8+
export CFLAGS="-I$PREFIX/include $CFLAGS"
9+
$PYTHON -m pip install --no-build-isolation --no-deps .
10+

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "1.3.6" %}
1+
{% set version = "1.3.7" %}
22
{% set buildnumber = 0 %}
33

44
package:

mkl_fft/_pydfti.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#cython: language_level=3
2828

2929
# imports
30+
import sys
3031
import numpy as np
3132
from numpy.core._multiarray_tests import internal_overlap
3233
from threading import local as threading_local
@@ -48,13 +49,14 @@ cdef void _capsule_destructor(object caps) noexcept:
4849
cdef DftiCache *_cache = NULL
4950
cdef int status = 0
5051
if (caps is None):
51-
print("Nothing to destroy")
52+
print("CapsuleDestructorInternalError: Nothing to destroy", file=sys.stderr)
5253
return
5354
_cache = <DftiCache *>cpython.pycapsule.PyCapsule_GetPointer(caps, capsule_name)
5455
status = _free_dfti_cache(_cache)
5556
PyMem_Free(_cache)
5657
if (status != 0):
57-
raise ValueError("Internal Error: Freeing DFTI Cache returned with error = {}".format(status))
58+
print("CapsuleDestructorInternalError: Freeing DFTI Cache "
59+
f"returned with error code = '{status}'", file=sys.stderr)
5860

5961

6062
def _tls_dfti_cache_capsule():

mkl_fft/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.3.6'
1+
__version__ = '1.3.7'

mkl_fft/tests/test_fft1d.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2017-2019, Intel Corporation
2+
# Copyright (c) 2017-2023, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@
2626

2727
import numpy as np
2828
from numpy.testing import (
29-
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
29+
TestCase, assert_, assert_raises, assert_equal,
3030
assert_warns, assert_allclose)
3131
from numpy import random as rnd
3232
import sys
@@ -387,5 +387,3 @@ def test5(self):
387387
f2 = mkl_fft.rfft(f1, axis=a, overwrite_x=ovwr_x)
388388
assert_allclose(f2, self.t3.astype(dt), atol=atol)
389389

390-
if __name__ == "__main__":
391-
run_module_suite(argv = sys.argv)

mkl_fft/tests/test_fftnd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (c) 2017-2019, Intel Corporation
2+
# Copyright (c) 2017-2023, Intel Corporation
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions are met:
@@ -26,7 +26,7 @@
2626

2727
import numpy as np
2828
from numpy.testing import (
29-
TestCase, run_module_suite, assert_, assert_raises, assert_equal,
29+
TestCase, assert_, assert_raises, assert_equal,
3030
assert_warns, assert_allclose)
3131
from numpy import random as rnd
3232
import sys

0 commit comments

Comments
 (0)