From dfeb5bd15367428f827fd37b2d624ae722d3cd15 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 28 Sep 2026 11:38:51 -0400 Subject: [PATCH 1/3] build: move from scikit-build to scikit-build-core Replace the setup.py build (which uses skbuild.setuptools_wrap internals) with scikit-build-core, and versioneer with setuptools-scm. Closes #2341. Assisted-by: ClaudeCode:claude-opus-5-5 --- .flake8 | 2 - .git_archival.txt | 3 + .gitattributes | 2 +- .github/workflows/coverity.yml | 10 +- .github/workflows/generate-coverage.yaml | 4 +- .github/workflows/generate-docs.yml | 7 +- .github/workflows/os-llvm-sycl-build.yml | 2 +- .gitignore | 1 - .pre-commit-config.yaml | 1 - CHANGELOG.md | 1 + CMakeLists.txt | 10 +- conda-recipe-cf/bld.bat | 2 - conda-recipe-cf/build.sh | 4 - conda-recipe-cf/meta.yaml | 12 +- conda-recipe/bld.bat | 2 - conda-recipe/build.sh | 4 - conda-recipe/meta.yaml | 17 +- docs/CMakeLists.txt | 2 +- docs/README.md | 2 +- .../beginners_guides/installation.rst | 2 +- .../contributor_guides/building.rst | 47 +- docs/doc_sources/license.rst | 10 - dpctl/CMakeLists.txt | 14 +- dpctl/__init__.py | 4 +- dpctl/_init_helper.py | 2 +- dpctl/_version.py | 683 ------------------ libsyclinterface/CMakeLists.txt | 8 +- .../cmake/modules/GetLevelZeroHeaders.cmake | 20 +- pyproject.toml | 52 +- scripts/_build_helper.py | 51 +- scripts/build_locally.py | 14 +- scripts/gen_coverage.py | 30 +- scripts/gen_docs.py | 27 +- setup.py | 55 -- 34 files changed, 155 insertions(+), 952 deletions(-) create mode 100644 .git_archival.txt delete mode 100644 dpctl/_version.py delete mode 100644 setup.py diff --git a/.flake8 b/.flake8 index 4d0b83f2e0..c1b9ce8321 100644 --- a/.flake8 +++ b/.flake8 @@ -6,8 +6,6 @@ extend-ignore = E203, W503 show-source = True exclude = - versioneer.py - dpctl/_version.py build conda.recipe .git diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 0000000000..7c5100942a --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,3 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ diff --git a/.gitattributes b/.gitattributes index f10261fb12..a94cb2f8c2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -dpctl/_version.py export-subst +.git_archival.txt export-subst diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index aa687db6c3..5046c2b714 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -26,7 +26,7 @@ jobs: - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - # versioneer needs the tags to compute the package version + # setuptools-scm needs the tags to compute the package version fetch-depth: 0 - name: Add Intel repository @@ -56,7 +56,7 @@ jobs: - name: Install dpctl dependencies run: | - pip install numpy cython setuptools"<80" scikit-build cmake ninja versioneer[toml]==0.29 + pip install numpy cython scikit-build-core setuptools-scm cython-cmake cmake ninja - name: Report compiler version run: | @@ -98,9 +98,9 @@ jobs: run: | set -o pipefail source "${ONEAPI_ROOT}/setvars.sh" - rm -rf _skbuild - # --skip-editable: the in-place build_ext already compiled everything - # Coverity needs to see, a pip install would only repeat it + rm -rf build + # --skip-editable: a regular install is enough for Coverity to see + # all compilation units cov-build --dir cov-int \ python scripts/build_locally.py --oneapi --skip-editable --verbose \ 2>&1 | tee cov-build.log diff --git a/.github/workflows/generate-coverage.yaml b/.github/workflows/generate-coverage.yaml index 72da636288..ee5817d395 100644 --- a/.github/workflows/generate-coverage.yaml +++ b/.github/workflows/generate-coverage.yaml @@ -93,7 +93,7 @@ jobs: - name: Install dpctl dependencies shell: bash -l {0} run: | - pip install numpy cython setuptools"<80" pytest pytest-cov scikit-build cmake coverage[toml] versioneer[toml]==0.29 + pip install numpy cython pytest pytest-cov scikit-build-core setuptools-scm cython-cmake cmake ninja coverage[toml] - name: Build dpctl with coverage shell: bash -l {0} @@ -113,7 +113,7 @@ jobs: shell: bash -l {0} run: | echo "Processing c-api-coverage" - DPCTL_LCOV_FN=$(find _skbuild -name dpctl.lcov) + DPCTL_LCOV_FN=$(find build/coverage -name dpctl.lcov) export DPCTL_LCOV_FN grep "/tmp" "$DPCTL_LCOV_FN" coveralls-lcov -v -n \ diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index 1a7efad084..a96d1500cc 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -59,10 +59,9 @@ jobs: if: ${{ !github.event.pull_request || github.event.action != 'closed' }} shell: bash -l {0} run: | - pip install numpy cython setuptools">=70.1" scikit-build cmake sphinx"<7.2" pydot graphviz furo \ + pip install numpy cython scikit-build-core setuptools-scm cython-cmake cmake ninja sphinx"<7.2" pydot graphviz furo \ sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx-design \ - sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling \ - versioneer[toml]==0.29 + sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -78,7 +77,7 @@ jobs: tar xf doxyrest-2.1.2-linux-amd64.tar.xz python scripts/gen_docs.py --doxyrest-root="$(pwd)/doxyrest-2.1.2-linux-amd64" --verbose --multiversion --clean || exit 1 python -c "import dpctl; print(dpctl.__version__)" || exit 1 - mv "$(find _skbuild -type d -path "*/cmake-install/docs/docs" | head -n 1)" ~/docs + mv build/docs/docs/docs ~/docs git clean -dfx git reset --hard - name: Publish docs diff --git a/.github/workflows/os-llvm-sycl-build.yml b/.github/workflows/os-llvm-sycl-build.yml index 9fb6f3a295..e3910b047e 100644 --- a/.github/workflows/os-llvm-sycl-build.yml +++ b/.github/workflows/os-llvm-sycl-build.yml @@ -124,7 +124,7 @@ jobs: - name: Install dpctl dependencies shell: bash -l {0} run: | - pip install numpy cython setuptools"<80" pytest scikit-build cmake ninja versioneer[toml]==0.29 + pip install numpy cython pytest scikit-build-core setuptools-scm cython-cmake cmake ninja - name: Checkout repo uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 diff --git a/.gitignore b/.gitignore index f8d185c7a9..91d0acde06 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,6 @@ __pycache__/ # CMake build and local install directory build -_skbuild build_cmake install diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9071e0288f..0302e17726 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,7 +57,6 @@ repos: rev: 26.5.1 hooks: - id: black - exclude: "versioneer.py|dpctl/_version.py" - repo: https://github.com/pycqa/isort rev: 9.0.1 hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index 728d81dc55..78d9c02852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Bump minimum NumPy version to 1.26 [gh-2192](https://github.com/IntelPython/dpctl/pull/2192) * Rewrote USM Python examples into a single example [gh-2292](https://github.com/IntelPython/dpctl/pull/2292) * Registered `DPCTL_PARTITION_AFFINITY_DOMAIN_UNKNOWN` enumerator when `DPCTLDevice_GetPartitionAffinityDomains` receives an unrecognized value from the SYCL runtime [gh-2324](https://github.com/IntelPython/dpctl/pull/2324) +* Build with `scikit-build-core` instead of `scikit-build` and `setuptools`, and compute the version with `setuptools-scm` instead of `versioneer` [gh-2341](https://github.com/IntelPython/dpctl/issues/2341) ### Deprecated * Deprecated `dpctl.program` submodule in favor of `dpctl.compiler`, which provides a better description of the purpose of the submodule in exposing DPC++ compilation-related functionality [gh-2317](https://github.com/IntelPython/dpctl/pull/2317) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d27c9d6c3..43cf5805ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ target_link_libraries(DpctlCAPI INTERFACE DPCTLSyclInterfaceHeaders) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dpctl/apis/include/ - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include + DESTINATION dpctl/include FILES_MATCHING REGEX "\\.h(pp)?$" ) @@ -137,9 +137,15 @@ file(GLOB _cmake_scripts ${CMAKE_SOURCE_DIR}/cmake/*.cmake) install(FILES ${_cmake_scripts} DESTINATION dpctl/resources/cmake ) +# Installed into the environment prefix, not site-packages +if(DEFINED SKBUILD_DATA_DIR) + set(_dpctl_config_dest ${SKBUILD_DATA_DIR}/lib/cmake/dpctl) +else() + set(_dpctl_config_dest lib/cmake/dpctl) +endif() install(FILES ${CMAKE_SOURCE_DIR}/cmake/dpctl-config.cmake - DESTINATION lib/cmake/dpctl + DESTINATION ${_dpctl_config_dest} ) if (DPCTL_GENERATE_DOCS) diff --git a/conda-recipe-cf/bld.bat b/conda-recipe-cf/bld.bat index 1c9e08701d..cbb6888018 100644 --- a/conda-recipe-cf/bld.bat +++ b/conda-recipe-cf/bld.bat @@ -2,8 +2,6 @@ REM A workaround for activate-dpcpp.bat issue to be addressed in 2021.4 set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%" set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%" -"%PYTHON%" setup.py clean --all - REM useful for building in resources constrained VMs (public CI) set "CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE" diff --git a/conda-recipe-cf/build.sh b/conda-recipe-cf/build.sh index 983ba5d76c..9e26df0fd3 100755 --- a/conda-recipe-cf/build.sh +++ b/conda-recipe-cf/build.sh @@ -10,10 +10,6 @@ export ICPXCFG ICXCFG="$(pwd)/icpx_for_conda.cfg" export ICXCFG -if [ -e "_skbuild" ]; then - ${PYTHON} setup.py clean --all -fi - export CC=icx export CXX=icpx diff --git a/conda-recipe-cf/meta.yaml b/conda-recipe-cf/meta.yaml index 649d053129..35ac8c8317 100644 --- a/conda-recipe-cf/meta.yaml +++ b/conda-recipe-cf/meta.yaml @@ -29,19 +29,13 @@ requirements: - pybind11 >=3.0.2 - intel-sycl-rt - intel-cmplr-lib-rt - # Ensure we are using latest version of setuptools, since we don't need - # editable environments for release. - - setuptools >=69 - - wheel >=0.43 - python-build >=1.1 - - scikit-build >=0.17.0 + - scikit-build-core >=0.11 + - setuptools-scm >=8 + - cython-cmake >=0.2 - cython >=3.1.0 # [py>=313] - cython >=3.0.10 # [py<313] - numpy - # WARNING: check with doc how to upgrade - - versioneer ==0.29 - # versioneer dependency - - tomli # [py<311] run: - python - {{ pin_compatible('intel-sycl-rt', min_pin='x.x', max_pin='x') }} diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index 2ff9e6cdcc..e56c241130 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -2,8 +2,6 @@ REM A workaround for activate-dpcpp.bat issue to be addressed in 2021.4 set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%" set "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%" -"%PYTHON%" setup.py clean --all - REM Overriding IPO is useful for building in resources constrained VMs (public CI) if DEFINED OVERRIDE_INTEL_IPO ( set "CMAKE_ARGS=%CMAKE_ARGS% -DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=FALSE" diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index e892602ede..3631c922cb 100755 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -13,10 +13,6 @@ export ICXCFG read -r GLIBC_MAJOR GLIBC_MINOR <<<"$(conda list '^sysroot_linux-64$' \ | tail -n 1 | awk '{print $2}' | grep -oP '\d+' | head -n 2 | tr '\n' ' ')" -if [ -e "_skbuild" ]; then - ${PYTHON} setup.py clean --all -fi - export CC=icx export CXX=icpx diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 83a2818ed0..b3613c1500 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -33,22 +33,13 @@ requirements: - pybind11 >=2.13 - {{ pin_compatible('intel-sycl-rt', min_pin='x.x', max_pin='x') }} - {{ pin_compatible('intel-cmplr-lib-rt', min_pin='x.x', max_pin='x') }} - # Ensure we are using latest version of setuptools, since we don't need - # editable environments for release. - - setuptools >=69 + - python-build >=1.1 + - wheel >=0.43 + - cmake >=3.29.0 + - ninja >=1.11.1 # [not win] {% for dep in py_build_deps %} - {% if dep.startswith('ninja') %} - - {{ dep.split(';')[0] }} # [not win] - {% elif dep.startswith('cmake') %} - - {{ dep }} - {% elif dep.startswith('build>=') %} - - {{ 'python-' ~ dep }} - {% else %} - {{ dep|replace('_','-') }} - {% endif %} {% endfor %} - # versioneer dependency - - tomli # [py<311] - opencl-headers >=2025.06.13 # [win] run: - python diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 0bd31e059c..43b394b125 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -168,7 +168,7 @@ if (DPCTL_ENABLE_DOXYREST) endif() # Set the location where the generated docs are saved -set(DOC_OUTPUT_DIR ${CMAKE_INSTALL_PREFIX}/docs) +set(DOC_OUTPUT_DIR ${CMAKE_BINARY_DIR}/docs) # set(INDEX_NO_DOXYREST_IN ${CMAKE_CURRENT_SOURCE_DIR}/index_no_doxyrest.rst.in) # set(INDEX_DOXYREST_IN ${CMAKE_CURRENT_SOURCE_DIR}/index_doxyrest.rst.in) diff --git a/docs/README.md b/docs/README.md index 03eb53600b..e15aa19a7e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,7 +34,7 @@ Generating The Documentation The helper script ``scripts/gen_docs.py`` is the preferred way to generate the documentation. The generated documentation HTML pages are installed to the -``CMAKE_INSTALL_PREFIX/docs`` directory. +``docs`` directory in the CMake build directory. ---------------------------- ```bash diff --git a/docs/doc_sources/beginners_guides/installation.rst b/docs/doc_sources/beginners_guides/installation.rst index edfa1b4dae..fc3cc843bd 100644 --- a/docs/doc_sources/beginners_guides/installation.rst +++ b/docs/doc_sources/beginners_guides/installation.rst @@ -131,7 +131,7 @@ One way to create such environment is as follows: conda create -n dev_dpctl -c conda-forge python=3.12 pip conda activate dev_dpctl - pip install --no-cache-dir numpy cython scikit-build cmake ninja pytest + pip install --no-cache-dir numpy cython cython-cmake scikit-build-core setuptools-scm cmake ninja pytest Using such environment and with DPC++ compiler activated, build the project using diff --git a/docs/doc_sources/contributor_guides/building.rst b/docs/doc_sources/contributor_guides/building.rst index e492a42b4f..a4d3dd63ae 100644 --- a/docs/doc_sources/contributor_guides/building.rst +++ b/docs/doc_sources/contributor_guides/building.rst @@ -84,23 +84,22 @@ After building the Conda package, install it by executing: conda install dpctl -Build and Install with scikit-build -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Build and Install with scikit-build-core +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To build using Python ``setuptools`` and ``scikit-build``, install the following Python packages: +To build with ``scikit-build-core``, install the following Python packages: - ``cython`` +- ``cython-cmake`` - ``numpy`` - ``cmake`` -- ``scikit-build`` +- ``scikit-build-core`` +- ``setuptools-scm`` - ``ninja`` -- ``versioneer`` - ``gtest`` (optional to run C API tests) - ``gmock`` (optional to run C API tests) - ``pytest`` (optional to run Python API tests) -Once the prerequisites are installed, building using ``scikit-build`` involves the usual steps. - To build and install, run: .. tab-set:: @@ -110,36 +109,19 @@ To build and install, run: .. code-block:: bash - python setup.py install -- -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx + CC=icx CXX=icpx python -m pip install --no-build-isolation . .. tab-item:: Windows :sync: win .. code-block:: bat - python setup.py install -- -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx - - -To develop, run: - -.. tab-set:: - - .. tab-item:: Linux - :sync: lnx - - .. code-block:: bash - - python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icpx - python -m pip install -e . - - .. tab-item:: Windows - :sync: win - - .. code-block:: bat + set CC=icx + set CXX=icx + python -m pip install --no-build-isolation . - python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=icx -DCMAKE_CXX_COMPILER:PATH=icx - python -m pip install -e . +To develop, add ``-e`` to make an editable install. Developing can be streamlined using the driver script: @@ -166,13 +148,12 @@ Building Using Custom DPC++ You can build dpctl from the source using the `DPC++ toolchain `_ instead of the DPC++ compiler that comes with oneAPI. -Following steps in the `Build and install with scikit-build`_ use a command-line option to set -the relevant CMake variables, for example: +Following steps in the `Build and install with scikit-build-core`_ set the compilers +with environment variables, for example: .. code-block:: bash - python setup.py build_ext --inplace -G Ninja -DCMAKE_C_COMPILER:PATH=$(which clang) -DCMAKE_CXX_COMPILER:PATH=$(which clang++) - python -m pip install -e . + CC=$(which clang) CXX=$(which clang++) python -m pip install --no-build-isolation -e . Or you can use the driver script: diff --git a/docs/doc_sources/license.rst b/docs/doc_sources/license.rst index 916d663e40..49822d0692 100644 --- a/docs/doc_sources/license.rst +++ b/docs/doc_sources/license.rst @@ -11,14 +11,4 @@ Data Parallel Control license All usage and contributions to the project are subject to the terms and conditions of this license. -Third party components and their licenses ------------------------------------------ - -:py:mod:`dpctl` vendors `versioneer `_ to generate it version from git history -of its sources. Versioneer has been placed in public domain per `license file `_ -in its original repository. - - .. _dpctl_license: https://github.com/IntelPython/dpctl/blob/master/LICENSE -.. _versioneer_license: https://github.com/python-versioneer/python-versioneer/blob/master/LICENSE -.. _versioneer_gh: https://github.com/python-versioneer/python-versioneer/ diff --git a/dpctl/CMakeLists.txt b/dpctl/CMakeLists.txt index a4378a03d0..9466745f95 100644 --- a/dpctl/CMakeLists.txt +++ b/dpctl/CMakeLists.txt @@ -2,8 +2,9 @@ find_package(Python REQUIRED COMPONENTS NumPy) # -t is to only Cythonize sources with timestamps newer than existing CXX files (if present) # -w is to set working directory (and correctly set __pyx_f[] array of filenames) -set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"") -find_package(Cython REQUIRED) +set(CYTHON_ARGS -t -w "${CMAKE_SOURCE_DIR}") +find_package(Cython MODULE REQUIRED VERSION 3.1) +include(UseCython) if(WIN32) string(CONCAT WARNING_FLAGS @@ -106,8 +107,7 @@ set(CMAKE_INSTALL_RPATH "$ORIGIN") function(build_dpctl_ext _trgt _src _dest) set(options SYCL) cmake_parse_arguments(BUILD_DPCTL_EXT "${options}" "RELATIVE_PATH" "" ${ARGN}) - add_cython_target(${_trgt} ${_src} CXX OUTPUT_VAR _generated_src) - set(_cythonize_trgt "${_trgt}_cythonize_pyx") + cython_transpile(${_src} LANGUAGE CXX OUTPUT_VARIABLE _generated_src) Python_add_library(${_trgt} MODULE WITH_SOABI ${_generated_src}) if (BUILD_DPCTL_EXT_SYCL) add_sycl_to_target(TARGET ${_trgt} SOURCES ${_generated_src}) @@ -164,18 +164,18 @@ function(build_dpctl_ext _trgt _src _dest) LIBRARY DESTINATION ${_dest}) install(FILES ${_generated_api_h} - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include/${_dest} + DESTINATION dpctl/include/${_dest} OPTIONAL) install(FILES ${_generated_public_h} - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include/${_dest} + DESTINATION dpctl/include/${_dest} OPTIONAL) if (DPCTL_GENERATE_COVERAGE) get_filename_component(_original_src_dir ${_src} DIRECTORY) file(RELATIVE_PATH _rel_dir ${CMAKE_SOURCE_DIR} ${_original_src_dir}) install(FILES ${_generated_src} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${_rel_dir} + DESTINATION ${_rel_dir} ) endif() diff --git a/dpctl/__init__.py b/dpctl/__init__.py index 11c4a3281f..92a8921670 100644 --- a/dpctl/__init__.py +++ b/dpctl/__init__.py @@ -60,7 +60,7 @@ ) from ._sycl_queue_manager import get_device_cached_queue from ._sycl_timer import SyclTimer -from ._version import get_versions +from ._version import __version__ # noqa: F401 from .enum_types import ( backend_type, device_type, @@ -151,6 +151,4 @@ def get_include(): return os.path.join(os.path.dirname(__file__), "include") -__version__ = get_versions()["version"] -del get_versions del _init_helper diff --git a/dpctl/_init_helper.py b/dpctl/_init_helper.py index 6092b6123a..ef4e21df6c 100644 --- a/dpctl/_init_helper.py +++ b/dpctl/_init_helper.py @@ -41,7 +41,7 @@ if is_linux: # forking is not supported by device drivers - # Configure subprocess (used by versioneer) to + # Configure subprocess to # use SPAWN method over FORK method to enable # use of gdb-oneapi to debug code launched by # native extensions that used dpctl C/C++ API diff --git a/dpctl/_version.py b/dpctl/_version.py deleted file mode 100644 index 9812b5afc6..0000000000 --- a/dpctl/_version.py +++ /dev/null @@ -1,683 +0,0 @@ - -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. -# Generated by versioneer-0.29 -# https://github.com/python-versioneer/python-versioneer - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys -from typing import Any, Callable, Dict, List, Optional, Tuple -import functools - - -def get_keywords() -> Dict[str, str]: - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "$Format:%d$" - git_full = "$Format:%H$" - git_date = "$Format:%ci$" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - VCS: str - style: str - tag_prefix: str - parentdir_prefix: str - versionfile_source: str - verbose: bool - - -def get_config() -> VersioneerConfig: - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "pep440" - cfg.tag_prefix = "" - cfg.parentdir_prefix = "dpctl-" - cfg.versionfile_source = "dpctl/_version.py" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -LONG_VERSION_PY: Dict[str, str] = {} -HANDLERS: Dict[str, Dict[str, Callable]] = {} - - -def register_vcs_handler(vcs: str, method: str) -> Callable: # decorator - """Create decorator to mark a method as the handler of a VCS.""" - def decorate(f: Callable) -> Callable: - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - return decorate - - -def run_command( - commands: List[str], - args: List[str], - cwd: Optional[str] = None, - verbose: bool = False, - hide_stderr: bool = False, - env: Optional[Dict[str, str]] = None, -) -> Tuple[Optional[str], Optional[int]]: - """Call the given command(s).""" - assert isinstance(commands, list) - process = None - - popen_kwargs: Dict[str, Any] = {} - if sys.platform == "win32": - # This hides the console window if pythonw.exe is used - startupinfo = subprocess.STARTUPINFO() - startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW - popen_kwargs["startupinfo"] = startupinfo - - for command in commands: - try: - dispcmd = str([command] + args) - # remember shell=False, so use git.cmd on windows, not just git - process = subprocess.Popen([command] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None), **popen_kwargs) - break - except OSError as e: - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = process.communicate()[0].strip().decode() - if process.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, process.returncode - return stdout, process.returncode - - -def versions_from_parentdir( - parentdir_prefix: str, - root: str, - verbose: bool, -) -> Dict[str, Any]: - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for _ in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return {"version": dirname[len(parentdir_prefix):], - "full-revisionid": None, - "dirty": False, "error": None, "date": None} - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print("Tried directories %s but none started with prefix %s" % - (str(rootdirs), parentdir_prefix)) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs: str) -> Dict[str, str]: - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords: Dict[str, str] = {} - try: - with open(versionfile_abs, "r") as fobj: - for line in fobj: - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - except OSError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords( - keywords: Dict[str, str], - tag_prefix: str, - verbose: bool, -) -> Dict[str, Any]: - """Get version information from git keywords.""" - if "refnames" not in keywords: - raise NotThisMethod("Short version file found") - date = keywords.get("date") - if date is not None: - # Use only the last line. Previous lines may contain GPG signature - # information. - date = date.splitlines()[-1] - - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = {r.strip() for r in refnames.strip("()").split(",")} - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = {r for r in refs if re.search(r'\d', r)} - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix):] - # Filter out refs that exactly match prefix or that don't start - # with a number once the prefix is stripped (mostly a concern - # when prefix is '') - if not re.match(r'\d', r): - continue - if verbose: - print("picking %s" % r) - return {"version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": None, - "date": date} - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return {"version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": "no suitable tags", "date": None} - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs( - tag_prefix: str, - root: str, - verbose: bool, - runner: Callable = run_command -) -> Dict[str, Any]: - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - # GIT_DIR can interfere with correct operation of Versioneer. - # It may be intended to be passed to the Versioneer-versioned project, - # but that should not change where we get our version from. - env = os.environ.copy() - env.pop("GIT_DIR", None) - runner = functools.partial(runner, env=env) - - _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=not verbose) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = runner(GITS, [ - "describe", "--tags", "--dirty", "--always", "--long", - "--match", f"{tag_prefix}[[:digit:]]*" - ], cwd=root) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces: Dict[str, Any] = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], - cwd=root) - # --abbrev-ref was added in git-1.6.3 - if rc != 0 or branch_name is None: - raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") - branch_name = branch_name.strip() - - if branch_name == "HEAD": - # If we aren't exactly on a branch, pick a branch which represents - # the current commit. If all else fails, we are on a branchless - # commit. - branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) - # --contains was added in git-1.5.4 - if rc != 0 or branches is None: - raise NotThisMethod("'git branch --contains' returned error") - branches = branches.split("\n") - - # Remove the first line if we're running detached - if "(" in branches[0]: - branches.pop(0) - - # Strip off the leading "* " from the list of branches. - branches = [branch[2:] for branch in branches] - if "master" in branches: - branch_name = "master" - elif not branches: - branch_name = None - else: - # Pick the first branch that is returned. Good or bad. - branch_name = branches[0] - - pieces["branch"] = branch_name - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[:git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) - if not mo: - # unparsable. Maybe git-describe is misbehaving? - pieces["error"] = ("unable to parse git-describe output: '%s'" - % describe_out) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = ("tag '%s' doesn't start with prefix '%s'" - % (full_tag, tag_prefix)) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix):] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) - pieces["distance"] = len(out.split()) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip() - # Use only the last line. Previous lines may contain GPG signature - # information. - date = date.splitlines()[-1] - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces: Dict[str, Any]) -> str: - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces: Dict[str, Any]) -> str: - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_branch(pieces: Dict[str, Any]) -> str: - """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . - - The ".dev0" means not master branch. Note that .dev0 sorts backwards - (a feature branch will appear "older" than the master branch). - - Exceptions: - 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0" - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += "+untagged.%d.g%s" % (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def pep440_split_post(ver: str) -> Tuple[str, Optional[int]]: - """Split pep440 version string at the post-release segment. - - Returns the release segments before the post-release and the - post-release version number (or -1 if no post-release segment is present). - """ - vc = str.split(ver, ".post") - return vc[0], int(vc[1] or 0) if len(vc) == 2 else None - - -def render_pep440_pre(pieces: Dict[str, Any]) -> str: - """TAG[.postN.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post0.devDISTANCE - """ - if pieces["closest-tag"]: - if pieces["distance"]: - # update the post release segment - tag_version, post_version = pep440_split_post(pieces["closest-tag"]) - rendered = tag_version - if post_version is not None: - rendered += ".post%d.dev%d" % (post_version + 1, pieces["distance"]) - else: - rendered += ".post0.dev%d" % (pieces["distance"]) - else: - # no commits, use the tag as the version - rendered = pieces["closest-tag"] - else: - # exception #1 - rendered = "0.post0.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces: Dict[str, Any]) -> str: - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_post_branch(pieces: Dict[str, Any]) -> str: - """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . - - The ".dev0" means not master branch. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["branch"] != "master": - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_old(pieces: Dict[str, Any]) -> str: - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces: Dict[str, Any]) -> str: - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces: Dict[str, Any]) -> str: - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces: Dict[str, Any], style: str) -> Dict[str, Any]: - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return {"version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None} - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-branch": - rendered = render_pep440_branch(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-post-branch": - rendered = render_pep440_post_branch(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return {"version": rendered, "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], "error": None, - "date": pieces.get("date")} - - -def get_versions() -> Dict[str, Any]: - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, - verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for _ in cfg.versionfile_source.split('/'): - root = os.path.dirname(root) - except NameError: - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None} - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", "date": None} diff --git a/libsyclinterface/CMakeLists.txt b/libsyclinterface/CMakeLists.txt index 774e1e9cef..5be76cce60 100644 --- a/libsyclinterface/CMakeLists.txt +++ b/libsyclinterface/CMakeLists.txt @@ -409,15 +409,15 @@ endif() install(TARGETS DPCTLSyclInterface LIBRARY - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl + DESTINATION dpctl ARCHIVE - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl + DESTINATION dpctl RUNTIME - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl + DESTINATION dpctl ) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ - DESTINATION ${CMAKE_INSTALL_PREFIX}/dpctl/include + DESTINATION dpctl/include FILES_MATCHING REGEX "\\.h(pp)?$" ) diff --git a/libsyclinterface/cmake/modules/GetLevelZeroHeaders.cmake b/libsyclinterface/cmake/modules/GetLevelZeroHeaders.cmake index 51d21c9ecd..52884099ff 100644 --- a/libsyclinterface/cmake/modules/GetLevelZeroHeaders.cmake +++ b/libsyclinterface/cmake/modules/GetLevelZeroHeaders.cmake @@ -13,7 +13,7 @@ # limitations under the License. # # The module uses git to clone the Level Zero source repository into the -# CMAKE_BINARY_DIR. The path to the Level Zero headers is then returned +# CMAKE_CURRENT_BINARY_DIR. The path to the Level Zero headers is then returned # to the caller in the LEVEL_ZERO_INCLUDE_DIR variable. # # Example usage: @@ -25,14 +25,15 @@ # LEVEL_ZERO_INCLUDE_DIR function(get_level_zero_headers) + set(LZ_DIR "${CMAKE_CURRENT_BINARY_DIR}/level-zero") - if(EXISTS "${CMAKE_BINARY_DIR}/level-zero/.git") + if(EXISTS ${LZ_DIR}) # Update the checkout execute_process( COMMAND ${GIT_EXECUTABLE} fetch RESULT_VARIABLE result ERROR_VARIABLE error - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/level-zero" + WORKING_DIRECTORY ${LZ_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) @@ -43,15 +44,12 @@ function(get_level_zero_headers) ) endif() else() - # remove level-zero directory if it exists - file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/level-zero") - # Clone the Level Zero git repo execute_process( COMMAND ${GIT_EXECUTABLE} clone https://github.com/oneapi-src/level-zero.git RESULT_VARIABLE result ERROR_VARIABLE error - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) @@ -69,7 +67,7 @@ function(get_level_zero_headers) RESULT_VARIABLE result OUTPUT_VARIABLE latest_tag ERROR_VARIABLE error - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/level-zero" + WORKING_DIRECTORY ${LZ_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) @@ -85,7 +83,7 @@ function(get_level_zero_headers) COMMAND ${GIT_EXECUTABLE} checkout ${latest_tag} RESULT_VARIABLE result ERROR_VARIABLE error - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/level-zero" + WORKING_DIRECTORY ${LZ_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE ) @@ -99,7 +97,7 @@ function(get_level_zero_headers) # Populate the path to the headers find_path(LEVEL_ZERO_INCLUDE_DIR NAMES zet_api.h - PATHS "${CMAKE_BINARY_DIR}/level-zero/include" + PATHS ${LZ_DIR}/include NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH @@ -115,4 +113,6 @@ function(get_level_zero_headers) ) endif() + set(LEVEL_ZERO_INCLUDE_DIR ${LEVEL_ZERO_INCLUDE_DIR} PARENT_SCOPE) + endfunction(get_level_zero_headers) diff --git a/pyproject.toml b/pyproject.toml index 4687ba827b..17b233a733 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,12 @@ [build-system] -build-backend = "setuptools.build_meta" +build-backend = "scikit_build_core.build" requires = [ # TODO: keep in sync with [project.dependencies] - "wheel>=0.43", - "build>=1.1", - "setuptools>=63.0.0", - "scikit-build>=0.17.0", - "ninja>=1.11.1; platform_system!='Windows'", - "cmake>=3.29.0", + "scikit-build-core>=0.11", + "setuptools-scm>=8", "cython>=3.1.0", - "numpy >=1.26.0", - # WARNING: check with doc how to upgrade - "versioneer[toml]==0.29" + "cython-cmake>=0.2", + "numpy >=1.26.0" ] [project] @@ -85,7 +80,6 @@ Issues = "https://github.com/IntelPython/dpctl/issues" Repository = "https://github.com/IntelPython/dpctl.git" [tool.black] -exclude = "dpctl/_version.py" line-length = 80 [tool.codespell] @@ -124,13 +118,11 @@ force_grid_wrap = 0 include_trailing_comma = true line_length = 80 multi_line_output = 3 -skip = ["dpctl/_version.py"] use_parentheses = true [tool.pytest.ini_options] addopts = [ "--junitxml=junit.xml", - "--ignore=setup.py", "--ignore=run_test.py", "--tb=native", "--strict-markers", @@ -150,9 +142,31 @@ norecursedirs = [ "conda-recipe" ] -[tool.versioneer] -VCS = "git" -parentdir_prefix = "dpctl-" -style = "pep440" -versionfile_build = "dpctl/_version.py" -versionfile_source = "dpctl/_version.py" +[tool.scikit-build] +build-dir = "build/{wheel_tag}" +metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" +minimum-version = "build-system.requires" +sdist.include = [ + "dpctl/apis/include/*.h", + "dpctl/tests/_c_ext.c" +] +wheel.exclude = [ + "dpctl/**/CMakeLists.txt", + "dpctl/**/*.pyx", + "!dpctl/tests/*.pyx", + "dpctl/**/*.pxi", + "dpctl/**/*.hpp", + "!dpctl/include/**", + "dpctl/.gitignore", + "dpctl/apis/", + "dpctl/utils/src/" +] +wheel.packages = ["dpctl"] + +[[tool.scikit-build.generate]] +path = "dpctl/_version.py" +template = ''' +__version__ = version = "${version}" +''' + +[tool.setuptools_scm] diff --git a/scripts/_build_helper.py b/scripts/_build_helper.py index dfbc86f46d..f256ae6e79 100644 --- a/scripts/_build_helper.py +++ b/scripts/_build_helper.py @@ -110,55 +110,42 @@ def make_cmake_args( return args -def build_extension( +def build_and_install( setup_dir: str, env: dict[str, str], cmake_args: list[str], + build_dir: str = None, cmake_executable: str = None, generator: str = None, build_type: str = None, + editable: bool = True, ): - cmd = [sys.executable, "setup.py", "build_ext", "--inplace"] - if cmake_executable: - cmd.append(f"--cmake-executable={cmake_executable}") - if generator: - cmd.append(f"--generator={generator}") + cmd = [sys.executable, "-m", "pip", "install", "--no-build-isolation", "-v"] + if editable: + cmd.append("-e") + cmd.append(".") + if build_dir: + cmd.append(f"--config-settings=build-dir={build_dir}") if build_type: - cmd.append(f"--build-type={build_type}") + cmd.append(f"--config-settings=cmake.build-type={build_type}") + cmake_args = [arg for arg in cmake_args if arg] if cmake_args: - cmd.append("--") - cmd += cmake_args - run( - cmd, - env=env, - cwd=setup_dir, - ) - - -def install_editable(setup_dir: str, env: dict[str, str]): - run( - [ - sys.executable, - "-m", - "pip", - "install", - "-e", - ".", - "--no-build-isolation", - ], - env=env, - cwd=setup_dir, - ) + cmd.append(f"--config-settings=cmake.args={';'.join(cmake_args)}") + if cmake_executable: + env["CMAKE_EXECUTABLE"] = cmake_executable + if generator: + env["CMAKE_GENERATOR"] = generator + run(cmd, env=env, cwd=setup_dir) -def clean_build_dir(setup_dir: str): +def clean_build_dir(setup_dir: str, build_dir: str = "build"): if ( not isinstance(setup_dir, str) or not setup_dir or not os.path.isdir(setup_dir) ): raise RuntimeError(f"Invalid setup directory provided: '{setup_dir}'") - target = os.path.join(setup_dir, "_skbuild") + target = os.path.join(setup_dir, build_dir) if os.path.exists(target): print(f"Cleaning build directory: {target}") try: diff --git a/scripts/build_locally.py b/scripts/build_locally.py index 6918a429e5..f750af2513 100644 --- a/scripts/build_locally.py +++ b/scripts/build_locally.py @@ -19,10 +19,9 @@ import sys from _build_helper import ( - build_extension, + build_and_install, clean_build_dir, err, - install_editable, log_cmake_args, make_cmake_args, resolve_compilers, @@ -126,7 +125,7 @@ def parse_args(): p.add_argument( "--skip-editable", action="store_true", - help="Skip pip editable install step", + help="Use a regular pip install instead of an editable install", ) return p.parse_args() @@ -170,22 +169,19 @@ def main(): log_cmake_args(cmake_args, "build_locally") - print("[build_locally] Building extensions in-place...") + print("[build_locally] Building and installing dpctl...") env = os.environ.copy() - build_extension( + build_and_install( setup_dir, env, cmake_args, cmake_executable=args.cmake_executable, generator=args.generator, build_type=args.build_type, + editable=not args.skip_editable, ) - if not args.skip_editable: - install_editable(setup_dir, env) - else: - print("[build_locally] Skipping editable install (--skip-editable)") print("[build_locally] Build complete") diff --git a/scripts/gen_coverage.py b/scripts/gen_coverage.py index f7e11c4ace..240533dc04 100644 --- a/scripts/gen_coverage.py +++ b/scripts/gen_coverage.py @@ -17,22 +17,24 @@ import argparse import os import re +import shutil import subprocess import sys import sysconfig from _build_helper import ( - build_extension, + build_and_install, capture_cmd_output, clean_build_dir, err, - install_editable, log_cmake_args, make_cmake_args, resolve_compilers, run, ) +BUILD_DIR = "build/coverage" + def find_bin_llvm(compiler): if os.path.isabs(compiler): @@ -148,7 +150,7 @@ def main(): bin_llvm = find_bin_llvm(c_compiler) if args.clean: - clean_build_dir(setup_dir) + clean_build_dir(setup_dir, BUILD_DIR) # Level Zero state (on unless explicitly disabled) level_zero_enabled = False if args.no_level_zero else True @@ -176,22 +178,28 @@ def main(): log_cmake_args(cmake_args, "gen_coverage") - build_extension( + build_and_install( setup_dir, env, cmake_args, + build_dir=BUILD_DIR, cmake_executable=args.cmake_executable, generator=args.generator, build_type="Coverage", ) - install_editable(setup_dir, env) - cmake_build_dir = capture_cmd_output( - ["find", "_skbuild", "-name", "cmake-build"], - cwd=setup_dir, - ) + cmake_build_dir = os.path.join(setup_dir, BUILD_DIR) - print(f"[gen_coverage] Found CMake build dir: {cmake_build_dir}") + # Cython.Coverage looks for the generated sources next to the .pyx files + cmake_pkg_dir = os.path.join(cmake_build_dir, "dpctl") + for root, _, files in os.walk(cmake_pkg_dir): + for file in files: + if file.endswith(".cxx"): + rel_dir = os.path.relpath(root, cmake_build_dir) + shutil.copy2( + os.path.join(root, file), + os.path.join(setup_dir, rel_dir, file), + ) run( ["cmake", "--build", ".", "--target", "llvm-cov-report"], @@ -228,7 +236,7 @@ def find_objects(): def is_py_ext(fn): return re.match(regexp, fn) - for root, _, files in os.walk("dpctl"): + for root, _, files in os.walk(cmake_build_dir): for file in files: if not file.endswith(".so"): continue diff --git a/scripts/gen_docs.py b/scripts/gen_docs.py index ea29fa6bf6..2101aaa644 100644 --- a/scripts/gen_docs.py +++ b/scripts/gen_docs.py @@ -16,21 +16,20 @@ import argparse import os -import subprocess import sys from _build_helper import ( - build_extension, - capture_cmd_output, + build_and_install, clean_build_dir, err, - install_editable, log_cmake_args, make_cmake_args, resolve_compilers, run, ) +BUILD_DIR = "build/docs" + def parse_args(): p = argparse.ArgumentParser(description="Build dpctl and generate coverage") @@ -125,7 +124,7 @@ def main(): ) if args.clean: - clean_build_dir(setup_dir) + clean_build_dir(setup_dir, BUILD_DIR) # Level Zero state (on unless explicitly disabled) level_zero_enabled = False if args.no_level_zero else True @@ -151,33 +150,23 @@ def main(): env = os.environ.copy() - build_extension( + build_and_install( setup_dir, env, cmake_args, + build_dir=BUILD_DIR, cmake_executable=args.cmake_executable, generator=args.generator, build_type="Release", ) - install_editable(setup_dir, env) - cmake_build_dir = capture_cmd_output( - ["find", "_skbuild", "-name", "cmake-build"], cwd=setup_dir - ) - - print(f"[gen_docs] Found CMake build dir: {cmake_build_dir}") + cmake_build_dir = os.path.join(setup_dir, BUILD_DIR) run( ["cmake", "--build", ".", "--target", "Sphinx"], cwd=cmake_build_dir, ) - generated_doc_dir = ( - subprocess.check_output( - ["find", "_skbuild", "-name", "index.html"], cwd=setup_dir - ) - .decode("utf-8") - .strip("\n") - ) + generated_doc_dir = os.path.join(cmake_build_dir, "docs", "docs") print("Generated documentation placed under ", generated_doc_dir) print("[gen_docs] Done") diff --git a/setup.py b/setup.py deleted file mode 100644 index d4c9987b1d..0000000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -# Data Parallel Control Library (dpctl) -# -# Copyright 2020 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import skbuild -import skbuild.setuptools_wrap -import skbuild.utils -import versioneer - -skbuild.setup( - version=versioneer.get_version(), - cmdclass=versioneer.get_cmdclass(), - url="https://github.com/IntelPython/dpctl", - packages=[ - "dpctl", - "dpctl.compiler", - "dpctl.compiler.utils", - "dpctl.memory", - "dpctl.program", - "dpctl.utils", - ], - package_data={ - "dpctl": [ - "tests/*.*", - "tests/helper/*.py", - "tests/elementwise/*.py", - "tests/*.pyx", - "tests/input_files/*", - "resources/cmake/*.cmake", - "include/*.h*", - "include/syclinterface/*.h*", - "include/syclinterface/Config/*.h", - "include/syclinterface/Support/*.h", - "include/dpctl/_sycl*.h", - "include/dpctl/memory/_memory*.h", - "include/dpctl/compiler/_compiler*.h", - "*.pxd", - "compiler/*.pxd", - "memory/*.pxd", - ] - }, - include_package_data=False, -) From b6b54cfc9d70f203bd731dce5d51348e19277cb8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 28 Sep 2026 11:49:29 -0400 Subject: [PATCH 2/3] build: move examples to scikit-build-core Assisted-by: ClaudeCode:claude-opus-5-5 --- .github/workflows/conda-package.yml | 8 ++--- docs/doc_sources/api_reference/index.rst | 4 +-- examples/cython/sycl_buffer/CMakeLists.txt | 9 +++-- examples/cython/sycl_buffer/README.md | 4 +-- examples/cython/sycl_buffer/pyproject.toml | 36 +++++++++++++++++++ examples/cython/sycl_buffer/setup.py | 33 ----------------- examples/cython/use_dpctl_sycl/CMakeLists.txt | 9 +++-- examples/cython/use_dpctl_sycl/README.md | 4 +-- examples/cython/use_dpctl_sycl/pyproject.toml | 36 +++++++++++++++++++ examples/cython/use_dpctl_sycl/setup.py | 33 ----------------- .../external_usm_allocation/CMakeLists.txt | 2 -- .../external_usm_allocation/README.md | 2 +- .../external_usm_allocation/pyproject.toml | 35 ++++++++++++++++++ .../pybind11/external_usm_allocation/setup.py | 26 -------------- examples/pybind11/onemkl_gemv/CMakeLists.txt | 2 -- examples/pybind11/onemkl_gemv/README.md | 26 ++++++-------- examples/pybind11/onemkl_gemv/pyproject.toml | 35 ++++++++++++++++++ examples/pybind11/onemkl_gemv/setup.py | 26 -------------- .../use_dpctl_sycl_kernel/CMakeLists.txt | 2 -- .../pybind11/use_dpctl_sycl_kernel/README.md | 2 +- .../use_dpctl_sycl_kernel/pyproject.toml | 35 ++++++++++++++++++ .../pybind11/use_dpctl_sycl_kernel/setup.py | 26 -------------- .../use_dpctl_sycl_queue/CMakeLists.txt | 2 -- .../pybind11/use_dpctl_sycl_queue/README.md | 2 +- .../use_dpctl_sycl_queue/pyproject.toml | 35 ++++++++++++++++++ .../pybind11/use_dpctl_sycl_queue/setup.py | 26 -------------- 26 files changed, 244 insertions(+), 216 deletions(-) create mode 100644 examples/cython/sycl_buffer/pyproject.toml delete mode 100644 examples/cython/sycl_buffer/setup.py create mode 100644 examples/cython/use_dpctl_sycl/pyproject.toml delete mode 100644 examples/cython/use_dpctl_sycl/setup.py create mode 100644 examples/pybind11/external_usm_allocation/pyproject.toml delete mode 100644 examples/pybind11/external_usm_allocation/setup.py create mode 100644 examples/pybind11/onemkl_gemv/pyproject.toml delete mode 100644 examples/pybind11/onemkl_gemv/setup.py create mode 100644 examples/pybind11/use_dpctl_sycl_kernel/pyproject.toml delete mode 100644 examples/pybind11/use_dpctl_sycl_kernel/setup.py create mode 100644 examples/pybind11/use_dpctl_sycl_queue/pyproject.toml delete mode 100644 examples/pybind11/use_dpctl_sycl_queue/setup.py diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 3cce876e44..09e539e547 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -687,8 +687,8 @@ jobs: conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y cmake ninja $CHANNELS || exit 1 echo "Cmake and Ninja installed" # shellcheck disable=SC2086 - conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y pybind11 cython scikit-build $CHANNELS || exit 1 - echo "scikit-build installed" + conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y pybind11 cython cython-cmake scikit-build-core $CHANNELS || exit 1 + echo "scikit-build-core installed" # shellcheck disable=SC2086 conda install -n ${{ env.EXAMPLES_ENV_NAME }} -y mkl-dpcpp \ mkl-devel-dpcpp dpcpp_cpp_rt "${DPCTL_DEPENDS}" \ @@ -720,7 +720,7 @@ jobs: while IFS= read -r d; do pushd "$d" > /dev/null conda activate --stack build_env - CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1 + CC=icx CXX=icpx python -m pip install --no-build-isolation --no-deps -e . || exit 1 conda deactivate if [ -e tests ]; then LD_LIBRARY_PATH="${CONDA_PREFIX}/lib" python -m pytest tests || exit 1 @@ -739,7 +739,7 @@ jobs: while IFS= read -r d; do pushd "$d" > /dev/null conda activate --stack "${{ env.BUILD_ENV_NAME }}" - CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1 + CC=icx CXX=icpx python -m pip install --no-build-isolation --no-deps -e . || exit 1 conda deactivate python -m pytest tests || exit 1 popd > /dev/null diff --git a/docs/doc_sources/api_reference/index.rst b/docs/doc_sources/api_reference/index.rst index fbe3b1da63..72fff49a1a 100644 --- a/docs/doc_sources/api_reference/index.rst +++ b/docs/doc_sources/api_reference/index.rst @@ -17,14 +17,14 @@ The package ``dpctl`` provides * Extension generators - :ref:`Declarations ` for classes defined in :py:mod:`dpctl` and supporting functions for use in `Cython `_. - :ref:`Integration ` with `pybind11 `_ defines type casters connecting SYCL classes and Python classes, as well as defines C++ classes wrapping a Python object for :mod:`dpctl.memory` objects. - - :ref:`Integration ` with `CMake `_ to simplify building DPC++-based Python extension using `scikit-build `_. + - :ref:`Integration ` with `CMake `_ to simplify building DPC++-based Python extension using `scikit-build-core `_. * C API for DPC++ runtime - :doc:`DPCTLSyclInterface C library ` .. _cmake_docs: https://cmake.org/documentation/ .. _cython_docs: https://cython.readthedocs.io/en/latest/ -.. _skbuild_docs: https://scikit-build.readthedocs.io/en/latest/ +.. _skbuild_docs: https://scikit-build-core.readthedocs.io/en/latest/ .. _pybind11_docs: https://pybind11.readthedocs.io/en/stable/ .. toctree:: diff --git a/examples/cython/sycl_buffer/CMakeLists.txt b/examples/cython/sycl_buffer/CMakeLists.txt index a30fbb2f35..af90b9f5b8 100644 --- a/examples/cython/sycl_buffer/CMakeLists.txt +++ b/examples/cython/sycl_buffer/CMakeLists.txt @@ -19,13 +19,14 @@ find_package(Python REQUIRED COMPONENTS Development.Module NumPy) find_package(Dpctl REQUIRED) # -w is to set working directory (and correctly set __pyx_f[] array of filenames) -set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"") -find_package(Cython REQUIRED) +set(CYTHON_ARGS -t -w "${CMAKE_SOURCE_DIR}") +find_package(Cython MODULE REQUIRED VERSION 3.1) +include(UseCython) set(py_module_name _syclbuffer) set(_cy_source syclbuffer/_syclbuffer.pyx) -add_cython_target(${py_module_name} ${_cy_source} CXX OUTPUT_VAR _generated_cy_src) +cython_transpile(${_cy_source} LANGUAGE CXX OUTPUT_VARIABLE _generated_cy_src) Python_add_library(${py_module_name} MODULE WITH_SOABI ${_generated_cy_src}) add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_generated_cy_src}) target_include_directories(${py_module_name} PUBLIC src ${Dpctl_INCLUDE_DIRS}) @@ -42,5 +43,3 @@ foreach(_src_fn ${_sources}) ) endforeach() target_link_options(${py_module_name} PRIVATE -fsycl-device-code-split=per_kernel) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/cython/sycl_buffer/README.md b/examples/cython/sycl_buffer/README.md index 6cda697dcf..494ba0b54b 100644 --- a/examples/cython/sycl_buffer/README.md +++ b/examples/cython/sycl_buffer/README.md @@ -16,12 +16,12 @@ oneMKL. To compile the example on Linux, run: ```bash -CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja +CC=icx CXX=icpx python -m pip install --no-build-isolation -e . ``` On Windows, run: ```bash -CC=icx CXX=icx python setup.py build_ext --inplace -G Ninja +CC=icx CXX=icx python -m pip install --no-build-isolation -e . ``` ## Running diff --git a/examples/cython/sycl_buffer/pyproject.toml b/examples/cython/sycl_buffer/pyproject.toml new file mode 100644 index 0000000000..1ed3e32a41 --- /dev/null +++ b/examples/cython/sycl_buffer/pyproject.toml @@ -0,0 +1,36 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "cython>=3.1", + "cython-cmake>=0.2", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Corporation" }] +dependencies = ["dpctl", "numpy"] +description = "An example of Cython extension calling SYCL routines" +license = "Apache-2.0" +name = "syclbuffer" +version = "0.0.0" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/cython/sycl_buffer/setup.py b/examples/cython/sycl_buffer/setup.py deleted file mode 100644 index cba7882e83..0000000000 --- a/examples/cython/sycl_buffer/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2020 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="syclbuffer", - version="0.0.0", - description="An example of Cython extension calling SYCL routines", - long_description=""" - Example of using SYCL to work on host allocated NumPy array using - SYCL buffers and SYCL functions. - - See README.md for more details. - """, - license="Apache 2.0", - author="Intel Corporation", - url="https://github.com/IntelPython/dpctl", - packages=["syclbuffer"], -) diff --git a/examples/cython/use_dpctl_sycl/CMakeLists.txt b/examples/cython/use_dpctl_sycl/CMakeLists.txt index 9445ae08f3..23d9f5b7eb 100644 --- a/examples/cython/use_dpctl_sycl/CMakeLists.txt +++ b/examples/cython/use_dpctl_sycl/CMakeLists.txt @@ -19,13 +19,14 @@ find_package(Python REQUIRED COMPONENTS Development.Module NumPy) find_package(Dpctl REQUIRED) # -w is to set working directory (and correctly set __pyx_f[] array of filenames) -set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"") -find_package(Cython REQUIRED) +set(CYTHON_ARGS -t -w "${CMAKE_SOURCE_DIR}") +find_package(Cython MODULE REQUIRED VERSION 3.1) +include(UseCython) set(py_module_name _cython_api) set(_cy_source use_dpctl_sycl/_cython_api.pyx) -add_cython_target(${py_module_name} ${_cy_source} CXX OUTPUT_VAR _generated_cy_src) +cython_transpile(${_cy_source} LANGUAGE CXX OUTPUT_VARIABLE _generated_cy_src) Python_add_library(${py_module_name} MODULE WITH_SOABI ${_generated_cy_src}) add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_generated_cy_src}) target_include_directories(${py_module_name} PUBLIC include ${Dpctl_INCLUDE_DIRS}) @@ -42,5 +43,3 @@ foreach(_src_fn ${_sources}) ) endforeach() target_link_options(${py_module_name} PRIVATE -fsycl-device-code-split=per_kernel) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/cython/use_dpctl_sycl/README.md b/examples/cython/use_dpctl_sycl/README.md index e6041d12aa..d2a6744b29 100644 --- a/examples/cython/use_dpctl_sycl/README.md +++ b/examples/cython/use_dpctl_sycl/README.md @@ -11,12 +11,12 @@ written in Cython. To build the example on Linux, run: ```bash -CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja +CC=icx CXX=icpx python -m pip install --no-build-isolation -e . ``` On Windows, run: ```bash -CC=icx CXX=icx python setup.py build_ext --inplace -G Ninja +CC=icx CXX=icx python -m pip install --no-build-isolation -e . ``` ## Testing diff --git a/examples/cython/use_dpctl_sycl/pyproject.toml b/examples/cython/use_dpctl_sycl/pyproject.toml new file mode 100644 index 0000000000..b9998a6e24 --- /dev/null +++ b/examples/cython/use_dpctl_sycl/pyproject.toml @@ -0,0 +1,36 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "cython>=3.1", + "cython-cmake>=0.2", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Corporation" }] +dependencies = ["dpctl", "numpy"] +description = "An example of Cython extension calling SYCL Cython API" +license = "Apache-2.0" +name = "use_dpctl_sycl" +version = "0.0.0" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/cython/use_dpctl_sycl/setup.py b/examples/cython/use_dpctl_sycl/setup.py deleted file mode 100644 index 559de5476e..0000000000 --- a/examples/cython/use_dpctl_sycl/setup.py +++ /dev/null @@ -1,33 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2022 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="use_dpctl_sycl", - version="0.0.0", - description="An example of Cython extension calling SYCL Cython API", - long_description=""" - Example of using SYCL to work on host allocated NumPy array using - SYCL buffers and SYCL functions. - - See README.md for more details. - """, - license="Apache 2.0", - author="Intel Corporation", - url="https://github.com/IntelPython/dpctl", - packages=["use_dpctl_sycl"], -) diff --git a/examples/pybind11/external_usm_allocation/CMakeLists.txt b/examples/pybind11/external_usm_allocation/CMakeLists.txt index e3ef19d199..2a3f04ff7b 100644 --- a/examples/pybind11/external_usm_allocation/CMakeLists.txt +++ b/examples/pybind11/external_usm_allocation/CMakeLists.txt @@ -36,5 +36,3 @@ target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS}) install(TARGETS ${py_module_name} DESTINATION external_usm_allocation ) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/pybind11/external_usm_allocation/README.md b/examples/pybind11/external_usm_allocation/README.md index 71dcce3c0a..e5486bacb4 100644 --- a/examples/pybind11/external_usm_allocation/README.md +++ b/examples/pybind11/external_usm_allocation/README.md @@ -13,7 +13,7 @@ To build the example, run: ```bash source /opt/intel/oneapi/compiler/latest/env/vars.sh -CXX=icpx CC=icx python setup.py build_ext --inplace +CXX=icpx CC=icx python -m pip install --no-build-isolation -e . python -m pytest tests python example.py ``` diff --git a/examples/pybind11/external_usm_allocation/pyproject.toml b/examples/pybind11/external_usm_allocation/pyproject.toml new file mode 100644 index 0000000000..c71966449f --- /dev/null +++ b/examples/pybind11/external_usm_allocation/pyproject.toml @@ -0,0 +1,35 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "pybind11", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Scripting" }] +dependencies = ["dpctl", "numpy"] +description = "an example of SYCL-powered Python package (with pybind11)" +license = "Apache-2.0" +name = "external_usm_allocation" +version = "0.0.1" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/pybind11/external_usm_allocation/setup.py b/examples/pybind11/external_usm_allocation/setup.py deleted file mode 100644 index 92f295bb09..0000000000 --- a/examples/pybind11/external_usm_allocation/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2021 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="external_usm_allocation", - version="0.0.1", - description="an example of SYCL-powered Python package (with pybind11)", - author="Intel Scripting", - license="Apache 2.0", - packages=["external_usm_allocation"], -) diff --git a/examples/pybind11/onemkl_gemv/CMakeLists.txt b/examples/pybind11/onemkl_gemv/CMakeLists.txt index 5a41b021b2..c42a82b100 100644 --- a/examples/pybind11/onemkl_gemv/CMakeLists.txt +++ b/examples/pybind11/onemkl_gemv/CMakeLists.txt @@ -65,5 +65,3 @@ target_compile_options(standalone_cpp ) target_include_directories(standalone_cpp PUBLIC sycl_gemm) target_link_libraries(standalone_cpp PRIVATE MKL::MKL_SYCL) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/pybind11/onemkl_gemv/README.md b/examples/pybind11/onemkl_gemv/README.md index f3b1f2d2b5..c2f0b54e7b 100644 --- a/examples/pybind11/onemkl_gemv/README.md +++ b/examples/pybind11/onemkl_gemv/README.md @@ -3,28 +3,24 @@ ## Building -> **NOTE:** Install scikit-build and dpcpp before next steps. +> **NOTE:** Install scikit-build-core, pybind11, and dpcpp before next steps. To build on Linux, run: ```bash -python setup.py build_ext --inplace -- -G "Ninja" \ - -DCMAKE_C_COMPILER:PATH=icx \ - -DCMAKE_CXX_COMPILER:PATH=icpx \ - -DTBB_LIBRARY_DIR=$CONDA_PREFIX/lib \ - -DMKL_LIBRARY_DIR=${CONDA_PREFIX}/lib \ - -DMKL_INCLUDE_DIR=${CONDA_PREFIX}/include \ - -DTBB_INCLUDE_DIR=${CONDA_PREFIX}/include +CC=icx CXX=icpx python -m pip install --no-build-isolation -e . \ + -Ccmake.define.TBB_LIBRARY_DIR=$CONDA_PREFIX/lib \ + -Ccmake.define.MKL_LIBRARY_DIR=${CONDA_PREFIX}/lib \ + -Ccmake.define.MKL_INCLUDE_DIR=${CONDA_PREFIX}/include \ + -Ccmake.define.TBB_INCLUDE_DIR=${CONDA_PREFIX}/include ``` To build on Windows, run: ```bash -python setup.py build_ext --inplace -- -G "Ninja" \ - -DCMAKE_C_COMPILER:PATH=icx \ - -DCMAKE_CXX_COMPILER:PATH=icx \ - -DTBB_LIBRARY_DIR=$CONDA_PREFIX/lib \ - -DMKL_LIBRARY_DIR=${CONDA_PREFIX}/lib \ - -DMKL_INCLUDE_DIR=${CONDA_PREFIX}/include \ - -DTBB_INCLUDE_DIR=${CONDA_PREFIX}/include +CC=icx CXX=icx python -m pip install --no-build-isolation -e . \ + -Ccmake.define.TBB_LIBRARY_DIR=$CONDA_PREFIX/lib \ + -Ccmake.define.MKL_LIBRARY_DIR=${CONDA_PREFIX}/lib \ + -Ccmake.define.MKL_INCLUDE_DIR=${CONDA_PREFIX}/include \ + -Ccmake.define.TBB_INCLUDE_DIR=${CONDA_PREFIX}/include ``` ## Running diff --git a/examples/pybind11/onemkl_gemv/pyproject.toml b/examples/pybind11/onemkl_gemv/pyproject.toml new file mode 100644 index 0000000000..6fcb280590 --- /dev/null +++ b/examples/pybind11/onemkl_gemv/pyproject.toml @@ -0,0 +1,35 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "pybind11", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Scripting" }] +dependencies = ["dpctl", "numpy"] +description = "an example of SYCL-powered Python package (with pybind11)" +license = "Apache-2.0" +name = "sycl_gemm" +version = "0.0.1" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/pybind11/onemkl_gemv/setup.py b/examples/pybind11/onemkl_gemv/setup.py deleted file mode 100644 index 40de3b2e5b..0000000000 --- a/examples/pybind11/onemkl_gemv/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2022 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="sycl_gemm", - version="0.0.1", - description="an example of SYCL-powered Python package (with pybind11)", - author="Intel Scripting", - license="Apache 2.0", - packages=["sycl_gemm"], -) diff --git a/examples/pybind11/use_dpctl_sycl_kernel/CMakeLists.txt b/examples/pybind11/use_dpctl_sycl_kernel/CMakeLists.txt index f48b8c83cf..a6477e8cef 100644 --- a/examples/pybind11/use_dpctl_sycl_kernel/CMakeLists.txt +++ b/examples/pybind11/use_dpctl_sycl_kernel/CMakeLists.txt @@ -35,5 +35,3 @@ target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS}) install(TARGETS ${py_module_name} DESTINATION use_kernel ) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/pybind11/use_dpctl_sycl_kernel/README.md b/examples/pybind11/use_dpctl_sycl_kernel/README.md index 34fa8d96ad..97f049f80d 100644 --- a/examples/pybind11/use_dpctl_sycl_kernel/README.md +++ b/examples/pybind11/use_dpctl_sycl_kernel/README.md @@ -12,7 +12,7 @@ Pybind11 extensions. To build the extension, run: ``` source /opt/intel/oneapi/compiler/latest/env/vars.sh -CXX=icpx python setup.py build_ext --inplace +CXX=icpx python -m pip install --no-build-isolation -e . python -m pytest tests python example.py ``` diff --git a/examples/pybind11/use_dpctl_sycl_kernel/pyproject.toml b/examples/pybind11/use_dpctl_sycl_kernel/pyproject.toml new file mode 100644 index 0000000000..7966a206bb --- /dev/null +++ b/examples/pybind11/use_dpctl_sycl_kernel/pyproject.toml @@ -0,0 +1,35 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "pybind11", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Scripting" }] +dependencies = ["dpctl", "numpy"] +description = "an example of SYCL-powered Python package (with pybind11)" +license = "Apache-2.0" +name = "use_kernel" +version = "0.0.1" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/pybind11/use_dpctl_sycl_kernel/setup.py b/examples/pybind11/use_dpctl_sycl_kernel/setup.py deleted file mode 100644 index 3dd470e50c..0000000000 --- a/examples/pybind11/use_dpctl_sycl_kernel/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2022 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="use_kernel", - version="0.0.1", - description="an example of SYCL-powered Python package (with pybind11)", - author="Intel Scripting", - license="Apache 2.0", - packages=["use_kernel"], -) diff --git a/examples/pybind11/use_dpctl_sycl_queue/CMakeLists.txt b/examples/pybind11/use_dpctl_sycl_queue/CMakeLists.txt index b3a16c6f62..5ad6c53fce 100644 --- a/examples/pybind11/use_dpctl_sycl_queue/CMakeLists.txt +++ b/examples/pybind11/use_dpctl_sycl_queue/CMakeLists.txt @@ -34,5 +34,3 @@ target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS}) install(TARGETS ${py_module_name} DESTINATION use_queue_device ) - -set(ignoreMe "${SKBUILD}") diff --git a/examples/pybind11/use_dpctl_sycl_queue/README.md b/examples/pybind11/use_dpctl_sycl_queue/README.md index 5eb8cbc1ef..c73c6bce9a 100644 --- a/examples/pybind11/use_dpctl_sycl_queue/README.md +++ b/examples/pybind11/use_dpctl_sycl_queue/README.md @@ -12,7 +12,7 @@ extensions. To build the extension, run: ``` source /opt/intel/oneapi/compiler/latest/env/vars.sh -CXX=icpx python setup.py build_ext --inplace +CXX=icpx python -m pip install --no-build-isolation -e . python -m pytest tests python example.py ``` diff --git a/examples/pybind11/use_dpctl_sycl_queue/pyproject.toml b/examples/pybind11/use_dpctl_sycl_queue/pyproject.toml new file mode 100644 index 0000000000..9d73af1357 --- /dev/null +++ b/examples/pybind11/use_dpctl_sycl_queue/pyproject.toml @@ -0,0 +1,35 @@ +# Data Parallel Control (dpctl) +# +# Copyright 2026 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +build-backend = "scikit_build_core.build" +requires = [ + "scikit-build-core>=0.11", + "pybind11", + "dpctl", + "numpy" +] + +[project] +authors = [{ name = "Intel Scripting" }] +dependencies = ["dpctl", "numpy"] +description = "an example of SYCL-powered Python package (with pybind11)" +license = "Apache-2.0" +name = "use_queue_device" +version = "0.0.1" + +[project.urls] +Repository = "https://github.com/IntelPython/dpctl" diff --git a/examples/pybind11/use_dpctl_sycl_queue/setup.py b/examples/pybind11/use_dpctl_sycl_queue/setup.py deleted file mode 100644 index 1b53d74668..0000000000 --- a/examples/pybind11/use_dpctl_sycl_queue/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -# Data Parallel Control (dpctl) -# -# Copyright 2021 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from skbuild import setup - -setup( - name="use_queue_device", - version="0.0.1", - description="an example of SYCL-powered Python package (with pybind11)", - author="Intel Scripting", - license="Apache 2.0", - packages=["use_queue_device"], -) From 3cc22ba9739ab90f4a33bf715ec299629bb282e2 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 29 Sep 2026 14:42:29 -0400 Subject: [PATCH 3/3] fix: support editable installs and Ninja in conda Windows builds Find installed data next to a compiled module, since editable installs keep Python files in the source tree. Clear the VS generator platform and toolset in bld.bat, which Ninja rejects. Assisted-by: ClaudeCode:claude-opus-5-5 --- conda-recipe-cf/bld.bat | 3 +++ conda-recipe/bld.bat | 3 +++ dpctl/__init__.py | 5 ++++- dpctl/__main__.py | 4 +++- dpctl/_init_helper.py | 5 ++++- dpctl/tests/test_service.py | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/conda-recipe-cf/bld.bat b/conda-recipe-cf/bld.bat index cbb6888018..634cc12e87 100644 --- a/conda-recipe-cf/bld.bat +++ b/conda-recipe-cf/bld.bat @@ -20,6 +20,9 @@ set "CC=icx" set "CXX=icx" set "CMAKE_GENERATOR=Ninja" +:: Set by the VS activation, but not supported by Ninja +set "CMAKE_GENERATOR_PLATFORM=" +set "CMAKE_GENERATOR_TOOLSET=" :: Make CMake verbose set "VERBOSE=1" diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index e56c241130..b0611a7a50 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -18,6 +18,9 @@ set "CC=icx" set "CXX=icx" set "CMAKE_GENERATOR=Ninja" +:: Set by the VS activation, but not supported by Ninja +set "CMAKE_GENERATOR_PLATFORM=" +set "CMAKE_GENERATOR_TOOLSET=" :: Make CMake verbose set "VERBOSE=1" diff --git a/dpctl/__init__.py b/dpctl/__init__.py index 92a8921670..1684c3ed87 100644 --- a/dpctl/__init__.py +++ b/dpctl/__init__.py @@ -148,7 +148,10 @@ def get_include(): Extension modules that need to be compiled against dpctl should use this function to locate the appropriate include directory. """ - return os.path.join(os.path.dirname(__file__), "include") + # Not __file__: editable installs keep Python files in the source tree + from . import _sycl_context + + return os.path.join(os.path.dirname(_sycl_context.__file__), "include") del _init_helper diff --git a/dpctl/__main__.py b/dpctl/__main__.py index c532431a41..66725023ca 100644 --- a/dpctl/__main__.py +++ b/dpctl/__main__.py @@ -24,7 +24,9 @@ def _dpctl_dir() -> str: - dpctl_dir = importlib.util.find_spec("dpctl").submodule_search_locations[0] + # Compiled modules are next to the installed data, also in editable mode + origin = importlib.util.find_spec("dpctl._sycl_context").origin + dpctl_dir = os.path.dirname(origin) abs_dpctl_dir = os.path.abspath(dpctl_dir) return abs_dpctl_dir diff --git a/dpctl/_init_helper.py b/dpctl/_init_helper.py index ef4e21df6c..d689385eae 100644 --- a/dpctl/_init_helper.py +++ b/dpctl/_init_helper.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import importlib.util import os import os.path import sys @@ -24,7 +25,9 @@ if sys.platform == "win32": # pragma: no cover # Include folder containing DPCTLSyclInterface.dll to search path - os.add_dll_directory(os.path.dirname(__file__)) + # Not __file__: editable installs keep Python files in the source tree + _origin = importlib.util.find_spec("dpctl._sycl_context").origin + os.add_dll_directory(os.path.dirname(_origin)) if is_venv: # For virtual environments on Windows, add folder # with DPC++ libraries to the DLL search path gh-1745 diff --git a/dpctl/tests/test_service.py b/dpctl/tests/test_service.py index b5b4fe23e9..e429e94eea 100644 --- a/dpctl/tests/test_service.py +++ b/dpctl/tests/test_service.py @@ -156,7 +156,7 @@ def should_skip_syclinterface(request): def test_syclinterface(should_skip_syclinterface): - install_dir = os.path.dirname(os.path.abspath(dpctl.__file__)) + install_dir = os.path.dirname(dpctl.get_include()) paths = glob.glob(os.path.join(install_dir, "*DPCTLSyclInterface*")) if "linux" in sys.platform: if should_skip_syclinterface: