diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5ace460..7863596 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,3 +4,5 @@ updates: directory: "/" schedule: interval: "weekly" + day: "saturday" + rebase-strategy: "disabled" diff --git a/.github/workflows/build-with-clang.yml b/.github/workflows/build-with-clang.yml index 143cf04..43e7ab2 100644 --- a/.github/workflows/build-with-clang.yml +++ b/.github/workflows/build-with-clang.yml @@ -59,7 +59,7 @@ jobs: with: packages: | cython - setuptools + setuptools>=77 pytest - name: List oneAPI folder content diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 645f1d3..f3dd02d 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -18,9 +18,11 @@ env: jobs: build_linux: runs-on: ubuntu-latest + strategy: matrix: python: ["3.9", "3.10", "3.11", "3.12"] + steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 @@ -34,6 +36,7 @@ jobs: - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -48,8 +51,10 @@ jobs: - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Build conda package run: | CHANNELS="-c conda-forge -c https://software.repos.intel.com/python/conda --override-channels" @@ -61,6 +66,7 @@ jobs: $VERSIONS \ $CHANNELS \ conda-recipe + - name: Upload artifact uses: actions/upload-artifact@v4.6.2 with: @@ -75,6 +81,7 @@ jobs: python: ['3.9', '3.10', '3.11', '3.12'] env: conda-bld: C:\Miniconda\conda-bld\win-64\ + steps: - name: Cancel Previous Runs uses: styfle/cancel-workflow-action@0.12.1 @@ -86,6 +93,7 @@ jobs: fetch-depth: 0 - uses: conda-incubator/setup-miniconda@v3 with: + conda-remove-defaults: true auto-activate-base: true activate-environment: "" @@ -100,10 +108,13 @@ jobs: restore-keys: | ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + - name: Install conda-build run: conda install conda-build + - name: Build conda package run: conda build --no-test --python ${{ matrix.python }} -c https://software.repos.intel.com/python/conda -c conda-forge --override-channels conda-recipe + - name: Upload artifact uses: actions/upload-artifact@v4.6.2 with: @@ -128,10 +139,13 @@ jobs: uses: actions/download-artifact@v4 with: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH + - name: Install conda-build run: conda install conda-build + - name: Create conda channel run: | mkdir -p $GITHUB_WORKSPACE/channel/linux-64 @@ -141,6 +155,7 @@ jobs: # Test channel conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json cat ver.json + - name: Collect dependencies run: | . $CONDA/etc/profile.d/conda.sh @@ -148,9 +163,11 @@ jobs: export PACKAGE_VERSION=$(python -c "${VER_SCRIPT1} ${VER_SCRIPT2}") conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} python=${{ matrix.python }} $CHANNELS --only-deps --dry-run > lockfile cat lockfile + - name: Set pkgs_dirs run: | echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc + - name: Cache conda packages uses: actions/cache@v4 env: @@ -171,6 +188,7 @@ jobs: conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${PACKAGE_VERSION} pytest python=${{ matrix.python }} $CHANNELS # Test installed packages conda list + - name: Run tests run: | . $CONDA/etc/profile.d/conda.sh @@ -197,11 +215,13 @@ jobs: name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} - uses: conda-incubator/setup-miniconda@v3 with: + conda-remove-defaults: true auto-activate-base: true activate-environment: "" + - name: Install conda-build - # Needed to be able to run conda index run: conda install conda-build + - name: Create conda channel run: | mkdir ${{ env.GITHUB_WORKSPACE }}\channel\win-64 @@ -210,6 +230,7 @@ jobs: # Test channel conda search ${{ env.PACKAGE_NAME }} -c ${{ env.GITHUB_WORKSPACE }}/channel --override-channels --info --json > ${{ env.GITHUB_WORKSPACE }}\ver.json more ${{ env.GITHUB_WORKSPACE }}\ver.json + - name: Collect dependencies shell: cmd run: | @@ -221,6 +242,7 @@ jobs: ) conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} --only-deps --dry-run > lockfile more lockfile + - name: Cache conda packages uses: actions/cache@v4 env: @@ -232,6 +254,7 @@ jobs: restore-keys: | ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}- ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}- + # add intel-openmp as an explicit dependency # to avoid it being missed when package version is specified exactly - name: Install mkl-service @@ -247,6 +270,7 @@ jobs: conda create -n ${{ env.TEST_ENV_NAME }} ${{ env.PACKAGE_NAME }}=%PACKAGE_VERSION% %WORKAROUND_DEPENDENCIES% pytest python=${{ matrix.python }} -c ${{ env.GITHUB_WORKSPACE }}/channel ${{ env.CHANNELS }} # Test installed packages conda list + - name: Run tests run: | conda activate -n ${{ env.TEST_ENV_NAME }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f5c46..f2b6840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,5 @@ -===================== `mkl-service` changelog -===================== +======================= 2.3.0 ===== diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index 34cc92b..0eddfe9 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -2,5 +2,5 @@ @rem Remember to activate compiler, if needed set MKLROOT=%CONDA_PREFIX% -%PYTHON% setup.py install +%PYTHON% -m pip install --no-build-isolation --no-deps . if errorlevel 1 exit 1 diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index 80a06a9..df09449 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -2,4 +2,4 @@ # make sure that compiler has been sourced, if necessary -MKLROOT=$CONDA_PREFIX $PYTHON setup.py install +MKLROOT=$CONDA_PREFIX $PYTHON -m pip install --no-build-isolation --no-deps . diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 0168f2f..d2aad92 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -19,12 +19,12 @@ requirements: - {{ compiler('c') }} host: - python - - setuptools - - mkl-devel >=2019.3 + - setuptools >=77 + - mkl-devel - cython run: - python - - mkl >=2019.3 + - mkl test: requires: @@ -40,7 +40,7 @@ about: license_file: LICENSE.txt license_family: BSD description: - Intel(R) Math Kernel Library (Intel(R) MKL) support functions are + Intel(R) OneAPI Math Kernel Library (OneMKL) support functions are subdivided into the following groups according to their purpose, such as Version Information Threading Control @@ -48,7 +48,7 @@ about: Memory Management Conditional Numerical Reproducibility Control Miscellaneous - summary: Python hooks for Intel(R) Math Kernel Library runtime control settings. + summary: Python hooks for Intel(R) OneMKL runtime control settings. extra: recipe-maintainers: diff --git a/mkl/__init__.py b/mkl/__init__.py index f46db4d..61af8ac 100644 --- a/mkl/__init__.py +++ b/mkl/__init__.py @@ -52,6 +52,4 @@ def __exit__(self, *args): del sys from ._py_mkl_service import * - - -__version__ = '2.4.2' +from ._version import __version__ diff --git a/mkl/_version.py b/mkl/_version.py new file mode 100644 index 0000000..60be088 --- /dev/null +++ b/mkl/_version.py @@ -0,0 +1 @@ +__version__ = "2.4.2" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5ec86b8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,77 @@ +# Copyright (c) 2025, Intel Corporation +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of Intel Corporation nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=77", "Cython"] + +[project] +authors = [ + {name = "Intel Corporation", email = "scripting@intel.com"} +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Programming Language :: C", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Software Development", + "Topic :: Utilities", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix" +] +dependencies = [] +description = "Python hooks for IntelĀ® OneAPI Math Kernel Library (OneMKL) runtime control settings" +dynamic = ["version"] +keywords = ["MKL"] +license = "BSD-3-Clause" +name = "mkl-service" +readme = {file = "README.md", content-type = "text/markdown"} +requires-python = ">=3.9,<3.13" + +[project.optional-dependencies] +test = ["pytest"] + +[project.urls] +Download = "http://github.com/IntelPython/mkl-service" +Homepage = "http://github.com/IntelPython/mkl-service" + +[tool.setuptools] +include-package-data = true +packages = ["mkl"] + +[tool.setuptools.dynamic] +version = {attr = "mkl._version.__version__"} + +[tool.setuptools.package-data] +"mkl" = ["tests/*.py"] diff --git a/setup.py b/setup.py index cf801a0..c350a35 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (c) 2018, Intel Corporation # # Redistribution and use in source and binary forms, with or without @@ -25,139 +24,67 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import division, print_function, absolute_import -import io -import re import os -from os.path import join, exists, dirname -import setuptools -import setuptools.extension - -with io.open('mkl/__init__.py', 'rt', encoding='utf8') as file: - VERSION = re.search(r'__version__ = \'(.*?)\'', file.read()).group(1) - -with open("README.md", "r", encoding="utf-8") as file: - long_description = file.read() - -CLASSIFIERS = """\ -Development Status :: 5 - Production/Stable -Intended Audience :: Science/Research -Intended Audience :: Developers -License :: OSI Approved -Programming Language :: C -Programming Language :: Python -Programming Language :: Python :: 3.9 -Programming Language :: Python :: 3.10 -Programming Language :: Python :: 3.11 -Programming Language :: Python :: 3.12 -Programming Language :: Python :: Implementation :: CPython -Topic :: Software Development -Topic :: Utilities -Operating System :: Microsoft :: Windows -Operating System :: POSIX -Operating System :: Unix -Operating System :: MacOS -""" - - -def get_extensions(): - mkl_root = os.environ['MKLROOT'] - mkl_info = { - 'include_dirs': [join(mkl_root, 'include')], - 'library_dirs': [join(mkl_root, 'lib'), join(mkl_root, 'lib', 'intel64')], - 'libraries': ['mkl_rt'] - } - - mkl_include_dirs = mkl_info.get('include_dirs', []) - mkl_library_dirs = mkl_info.get('library_dirs', []) - mkl_libraries = mkl_info.get('libraries', ['mkl_rt']) +from os.path import join + +import Cython.Build +from setuptools import Extension, setup + +def extensions(): + mkl_root = os.environ.get("MKLROOT", None) + if mkl_root: + mkl_info = { + "include_dirs": [join(mkl_root, "include")], + "library_dirs": [join(mkl_root, "lib"), join(mkl_root, "lib", "intel64")], + "libraries": ["mkl_rt"] + } + else: + raise ValueError("MKLROOT environment variable not set.") + + mkl_include_dirs = mkl_info.get("include_dirs", []) + mkl_library_dirs = mkl_info.get("library_dirs", []) + mkl_libraries = mkl_info.get("libraries", ["mkl_rt"]) defs = [] - if any(['mkl_rt' in li for li in mkl_libraries]): - #libs += ['dl'] - by default on Linux - defs += [('USING_MKL_RT', None)] - - pdir = 'mkl' - try: - from Cython.Build import cythonize - sources = [join(pdir, '_mkl_service.pyx')] - have_cython = True - except ImportError as e: - have_cython = False - sources = [join(pdir, '_mkl_service.c')] - if not exists(sources[0]): - raise ValueError(str(e) + '. ' + - 'Cython is required to build the initial .c file.') + if any(["mkl_rt" in li for li in mkl_libraries]): + #libs += ["dl"] - by default on Linux + defs += [("USING_MKL_RT", None)] extensions = [] extensions.append( - setuptools.extension.Extension( - 'mkl._mklinit', - sources=['mkl/_mklinitmodule.c'], - define_macros=defs, + Extension( + "mkl._mklinit", + sources=[join("mkl", "_mklinitmodule.c")], include_dirs=mkl_include_dirs, libraries=mkl_libraries + (["pthread"] if os.name == "posix" else []), library_dirs=mkl_library_dirs, extra_compile_args=[ - '-DNDEBUG' - # '-g', '-O2', '-Wall', - ] + "-DNDEBUG" + # "-g", "-O2", "-Wall", + ], + define_macros=defs, ) ) extensions.append( - setuptools.extension.Extension( - 'mkl._py_mkl_service', - sources=sources, + Extension( + "mkl._py_mkl_service", + sources=[join("mkl", "_mkl_service.pyx")], include_dirs=mkl_include_dirs, library_dirs=mkl_library_dirs, libraries=mkl_libraries, extra_compile_args=[ - '-DNDEBUG' - # '-g', '-O2', '-Wall', + "-DNDEBUG" + # "-g", "-O2", "-Wall", ] ) ) - if have_cython: - extensions = cythonize(extensions, include_path=[join(__file__, pdir)]) - return extensions -def setup_package(): - from setuptools import setup - metadata = dict( - name='mkl-service', - version=VERSION, - maintainer="Intel", - maintainer_email="scripting@intel.com", - description="MKL Support Functions", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/IntelPython/mkl-service", - author="Intel", - download_url="https://github.com/IntelPython/mkl-service", - license='BSD', - classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f], - platforms=["Windows", "Linux", "Mac OS-X"], - python_requires='>=3.9', - setup_requires=['setuptools', 'cython'], - install_requires=[], - packages=[ - "mkl", - ], - package_data={ - "mkl" : [ - "tests/*.*", - ] - }, - ext_modules=get_extensions() - ) - setup(**metadata) - - return None - - -if __name__ == '__main__': - setup_package() +setup( + cmdclass={"build_ext": Cython.Build.build_ext}, + ext_modules=extensions(), + zip_safe=False, +)