diff --git a/README.md b/README.md index 4b29281..56b3cba 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,50 @@ Where `` should be the latest version from https://software.repos ## Building -Intel(R) C compiler and Intel(R) Math Kernel Library are required to build `mkl_umath` from source: +Intel(R) C compiler and Intel(R) OneAPI Math Kernel Library (OneMKL) are required to build `mkl_umath` from source. +If these are installed as part of a `oneAPI` installation, the following packages must also be installed into the environment +- `cmake` +- `ninja` +- `cython` +- `scikit-build` +- `numpy` + +If build dependencies are to be installed with Conda, the following packages must be installed from the Intel(R) channel +- `mkl-devel` +- `dpcpp_linux-64` (or `dpcpp_win-64` for Windows) +- `numpy-base` + +then the remaining dependencies +- `cmake` +- `ninja` +- `cython` +- `scikit-build` + +and for `mkl-devel` and `dpcpp_linux-64` in a Conda environment, `MKLROOT` environment variable must be set +On Linux ```sh -# ensure that MKL is installed into Python prefix, Intel LLVM compiler is activated export MKLROOT=$CONDA_PREFIX -CC=icx pip install --no-build-isolation --no-deps -e . +``` + +On Windows +```sh +set MKLROOT=%CONDA_PREFIX% +``` + +If using `oneAPI`, it must be activated in the environment + +On Linux +``` +source ${ONEAPI_ROOT}/setvars.sh +``` + +On Windows +``` +call "%ONEAPI_ROOT%\setvars.bat" +``` + +finally, execute +``` +CC=icx pip install --no-build-isolation --no-deps . ``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..520743a --- /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 = [ + "cmake", + "ninja", + "scikit-build", + "setuptools>=77", + "Cython", + "numpy" +] + +[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 :: Scientific/Engineering", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix" +] +dependencies = ["numpy >=1.26.4", "mkl-service"] +description = "Intel (R) MKL-based universal functions for NumPy arrays" +dynamic = ["version"] +keywords = ["mkl_umath"] +license = "BSD-3-Clause" +name = "mkl_umath" +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_umath" +Homepage = "http://github.com/IntelPython/mkl_umath" + +[tool.setuptools.dynamic] +version = {attr = "mkl_umath._version.__version__"} diff --git a/setup.py b/setup.py index 0ee7fa6..fb126ee 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# Copyright (c) 2019-2023, Intel Corporation +# Copyright (c) 2019-2025, Intel Corporation # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -25,51 +24,19 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import importlib.machinery -import io -import os -import re -from distutils.dep_util import newer -from _vendored.conv_template import process_file as process_c_file -from os import (getcwd, environ, makedirs) -from os.path import join, exists, abspath, dirname -from setuptools import Extension +import sys +from setuptools.modified import newer +from os import makedirs +from os.path import join, exists, dirname import skbuild -import skbuild.setuptools_wrap -import skbuild.utils -from skbuild.command.build_py import build_py as _skbuild_build_py -from skbuild.command.install import install as _skbuild_install - -# import versioneer - -with io.open('mkl_umath/_version.py', 'rt', encoding='utf8') as f: - version = re.search(r'__version__ = \'(.*?)\'', f.read()).group(1) - -with open("README.md", "r", encoding="utf-8") as file: - long_description = file.read() - -VERSION = version - -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.6 -Programming Language :: Python :: 3.7 -Programming Language :: Python :: 3.8 -Programming Language :: Python :: Implementation :: CPython -Topic :: Software Development -Topic :: Scientific/Engineering -Operating System :: Microsoft :: Windows -Operating System :: POSIX -Operating System :: Unix -Operating System :: MacOS -""" + +sys.path.insert(0, dirname(__file__)) # Ensures local imports work +from _vendored.conv_template import process_file as process_c_file +# TODO: rewrite generation in CMake, see NumPy meson implementation +# https://github.com/numpy/numpy/blob/c6fb3357541fd8cf6e4faeaeda3b1a9065da0520/numpy/_core/meson.build#L623 def load_module(name, fn): """ Credit: numpy.compat.npy_load_module @@ -127,28 +94,9 @@ def generate_umath_c(build_dir): skbuild.setup( - name="mkl_umath", - version=VERSION, - maintainer = "Intel Corp.", - maintainer_email = "scripting@intel.com", - description = "MKL-based universal functions for NumPy arrays", - long_description = long_description, - long_description_content_type="text/markdown", - license = 'BSD', - author="Intel Corporation", - url="http://github.com/IntelPython/mkl_umath", - download_url="http://github.com/IntelPython/mkl_umath", packages=[ "mkl_umath", ], package_data={"mkl_umath": ["tests/*.*"]}, include_package_data=True, - zip_safe=False, - setup_requires=["Cython"], - install_requires=[ - "numpy", - ], - keywords="mkl_umath", - classifiers=[_f for _f in CLASSIFIERS.split("\n") if _f], - platforms=["Linux", "Windows"] )