Skip to content

Commit 81767b3

Browse files
committed
make mkl-service an optional dependency
mkl-service is only a dependency for the sake of the scipy interface, which is optional
1 parent 5eb587d commit 81767b3

File tree

7 files changed

+29
-22
lines changed

7 files changed

+29
-22
lines changed

.github/workflows/build_pip.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ jobs:
4444

4545
- name: Install MKL
4646
run: |
47-
conda install mkl-devel mkl-service
48-
python -c "import sys; print(sys.executable)"
49-
which python
50-
python -c "import mkl; print(mkl.__file__)"
47+
conda install mkl-devel mkl
5148
5249
- name: Build conda package
5350
run: |

.github/workflows/conda-package-cf.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
- name: Install mkl_fft
144144
run: |
145145
CHANNELS=(-c "$GITHUB_WORKSPACE"/channel ${{ env.CHANNELS }})
146-
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} ${{ matrix.numpy }} "$PACKAGE_NAME" pytest scipy "${CHANNELS[@]}"
146+
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} ${{ matrix.numpy }} "$PACKAGE_NAME" pytest scipy mkl-service "${CHANNELS[@]}"
147147
# Test installed packages
148148
conda list -n ${{ env.TEST_ENV_NAME }}
149149
@@ -318,7 +318,7 @@ jobs:
318318
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
319319
SET PACKAGE_VERSION=%%F
320320
)
321-
SET "TEST_DEPENDENCIES=pytest scipy"
321+
SET "TEST_DEPENDENCIES=pytest scipy mkl-service"
322322
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} ${{ matrix.numpy }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
323323
324324
- name: Report content of test environment

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
run: |
144144
CHANNELS=(-c "$GITHUB_WORKSPACE"/channel ${{ env.CHANNELS }})
145145
conda create -n ${{ env.TEST_ENV_NAME }} "$PACKAGE_NAME"=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} pytest "${CHANNELS[@]}"
146-
conda install -n ${{ env.TEST_ENV_NAME }} "scipy>=1.10" "${CHANNELS[@]}"
146+
conda install -n ${{ env.TEST_ENV_NAME }} "scipy>=1.10" "mkl-service" "${CHANNELS[@]}"
147147
# Test installed packages
148148
conda list -n ${{ env.TEST_ENV_NAME }}
149149
@@ -308,7 +308,7 @@ jobs:
308308
)
309309
SET "TEST_DEPENDENCIES=pytest"
310310
conda install -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %TEST_DEPENDENCIES% python=${{ matrix.python }} -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
311-
conda install -n ${{ env.TEST_ENV_NAME }} scipy -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
311+
conda install -n ${{ env.TEST_ENV_NAME }} scipy mkl-service -c ${{ env.workdir }}/channel ${{ env.CHANNELS }}
312312
}
313313
- name: Report content of test environment
314314
shell: cmd /C CALL {0}

conda-recipe-cf/meta.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ requirements:
2626
run:
2727
- python
2828
- python-gil # [py>=314]
29-
- mkl-service
29+
- {{ pin_compatible('mkl') }}
3030
- numpy
3131

3232
test:
@@ -35,6 +35,7 @@ test:
3535
requires:
3636
- pytest
3737
- scipy >=1.10
38+
- mkl-service
3839
imports:
3940
- mkl_fft
4041
- mkl_fft.interfaces

conda-recipe/meta.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ requirements:
4040
run:
4141
- python
4242
- python-gil # [py>=314]
43-
- mkl-service
43+
- {{ pin_compatible('mkl') }}
4444
{% if use_numpy_base %}
4545
- numpy-base
4646
{% else %}
@@ -52,8 +52,8 @@ test:
5252
- pytest -v --pyargs mkl_fft
5353
requires:
5454
- pytest
55-
# This is a temporary python restriction
56-
- scipy >=1.10 # [py<314]
55+
- scipy >=1.10
56+
- mkl-service
5757
imports:
5858
- mkl_fft
5959
- mkl_fft.interfaces

mkl_fft/interfaces/__init__.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,21 @@
2323
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2424
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525

26+
import importlib.util
27+
2628
from . import numpy_fft
2729

28-
# find scipy, not scipy.fft, to avoid circular dependency
29-
try:
30-
import scipy
31-
except ImportError:
32-
pass
33-
else:
34-
from . import scipy_fft
30+
__all__ = ["numpy_fft"]
31+
32+
_has_scipy = importlib.util.find_spec("scipy") is not None
33+
_has_mkl_service = importlib.util.find_spec("mkl") is not None
34+
35+
if _has_scipy:
36+
if not _has_mkl_service:
37+
pass
38+
else:
39+
from . import scipy_fft
40+
41+
__all__.append("scipy_fft")
42+
43+
del importlib, _has_scipy, _has_mkl_service

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ classifiers = [
5050
"Operating System :: POSIX",
5151
"Operating System :: Unix"
5252
]
53-
dependencies = ["numpy>=1.26.4", "mkl-service"]
53+
dependencies = ["numpy>=1.26.4", "mkl"]
5454
description = "MKL-based FFT transforms for NumPy arrays"
5555
dynamic = ["version"]
5656
keywords = ["DFTI", "FFT", "Fourier", "MKL"]
@@ -60,8 +60,8 @@ readme = {file = "README.md", content-type = "text/markdown"}
6060
requires-python = ">=3.10,<3.15"
6161

6262
[project.optional-dependencies]
63-
scipy_interface = ["scipy>=1.10"]
64-
test = ["pytest", "scipy>=1.10"]
63+
scipy_interface = ["scipy>=1.10", "mkl-service"]
64+
test = ["pytest", "scipy>=1.10", "mkl-service"]
6565

6666
[project.urls]
6767
Download = "http://github.com/IntelPython/mkl_fft"

0 commit comments

Comments
 (0)