Repository navigation
Build dpctl with scikit-build-core - #2345
ndgrigorian wants to merge 11 commits into
Conversation
fd7a5c2 to
2f74475
Compare
2f74475 to
1c2f892
Compare
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/2345/index.html |
1c2f892 to
0357abf
Compare
|
Sorry about the breakage! But I did give several months warning. :) |
It's no problem, your commits were quite helpful regardless of anything (especially with versioning). The PR to pin in CI for the time being is also open. :) |
2d16bc4 to
e520a55
Compare
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
Assisted-by: ClaudeCode:claude-opus-5-5
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
The loop over the undefined _sources set no options.
They install with the extension, so example.py and the tests find them in editable and regular installs alike.
Install scikit-build-core in the Windows open-source compiler workflow.
With the Visual Studio generator, the default on Windows, CMake uses MSVC regardless of CC and CXX.
With -w, cython writes its depfile relative to the source directory, which fails when the temporary build directory is on another drive.
Build the AdaptiveCpp examples with pip and point the C-API test steps at the scikit-build-core build directory.
fe55ce3 to
4bf1217
Compare
| __version__ = version = "${version}" | ||
| ''' | ||
|
|
||
| [tool.setuptools_scm] |
There was a problem hiding this comment.
Blocking: With its default version scheme, setuptools-scm fails on any commit after a X.Y.ZdevN tag with N ≥ 1, and dpctl makes such tags every cycle (0.22.0dev1, 0.23.0dev1). After the next 0.24.0dev1, pip install ., conda-build and cibuildwheel would all fail:
git tag 0.24.0dev1 HEAD~3
python -m setuptools_scm # ValueError: ... The 0.24.0.dev1 can't be bumped
git tag -d 0.24.0dev1With version_scheme = "post-release" under [tool.setuptools_scm] the same commit gets 0.24.0.dev1.post3+g<sha>.
| # -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}") |
There was a problem hiding this comment.
With -w, Cython writes the depfile relative to the source root, but Ninja reads it relative to the build dir and tracks dpctl/dpctl/_sycl_device.pxd, which does not exist. Every build re-runs Cython for all modules, and with -t a changed .pxd still does not regenerate the modules that cimport it. With set(CYTHON_ARGS) the deps work and __pyx_f[] stays dpctl/_sycl_queue.pyx. The examples use the same flags.
| [tool.scikit-build] | ||
| build-dir = "build/{wheel_tag}" | ||
| metadata.version.provider = "scikit_build_core.metadata.setuptools_scm" | ||
| minimum-version = "build-system.requires" |
There was a problem hiding this comment.
Without cmake>=3.29.0 in requires, scikit-build-core takes the minimum from cmake_minimum_required(VERSION 3.21...) and accepts a system CMake 3.22 (Ubuntu 22.04). The pybind11 FetchContent_Declare(... FIND_PACKAGE_ARGS ...) needs 3.24, so configure fails with URL_HASH is set to SHA256=...;FIND_PACKAGE_ARGS;NAMES;pybind11 but must be ALGO=value. cmake.version = ">=3.29" here would keep the old minimum.
| set(LZ_DIR "${CMAKE_CURRENT_BINARY_DIR}/level-zero") | ||
|
|
||
| if(EXISTS "${CMAKE_BINARY_DIR}/level-zero/.git") | ||
| if(EXISTS ${LZ_DIR}) |
There was a problem hiding this comment.
EXISTS ${LZ_DIR} is also true for a level-zero directory without .git. Then git fetch, describe and checkout run in the dpctl checkout itself, as the build dir is inside it: with an empty level-zero, the dpctl tree ends detached at its latest tag and configure fails on zet_api.h. Could it keep the .git check and the file(REMOVE_RECURSE ...) before the clone?
| set CC=icx | ||
| set CXX=icx | ||
| python -m pip install --no-build-isolation . |
There was a problem hiding this comment.
On Windows, scikit-build-core uses CMake's default generator, Visual Studio, unless CMAKE_GENERATOR is set, and that generator ignores CC and CXX (the examples' pyproject.toml says so too). So these commands would build with MSVC. Adding set CMAKE_GENERATOR=Ninja would match what build_locally.py and bld.bat do.
| # CMake build and local install directory | ||
| build | ||
| _skbuild | ||
| build_cmake |
There was a problem hiding this comment.
Nit: Existing checkouts keep their _skbuild/ tree, which now shows up in git status, and the sdist packs it, since scikit-build-core follows .gitignore. Keeping _skbuild here avoids both.
| * Changed the development packages on `dppy/label/dev` to build against conda-forge only, and the wheels there to declare `intel-sycl-rt` and `intel-cmplr-lib-rt` in their metadata, at least the compiler version they were built with [gh-2409](https://github.com/IntelPython/dpctl/pull/2409) | ||
| * Changed the conda recipe's tests to `pip check`, the import and `python -m dpctl -f`, as in the conda-forge feedstock, so `conda build` and `conda build --test` no longer run the test suite; run it with `ci/hooks.py`, or with `python -m pytest --pyargs dpctl` in an environment with dpctl installed [gh-2409](https://github.com/IntelPython/dpctl/pull/2409) | ||
| * Changed the install instructions in `README.md` and the documentation to conda-forge and PyPI [gh-2409](https://github.com/IntelPython/dpctl/pull/2409) | ||
| * Build with `scikit-build-core` instead of `scikit-build` and `setuptools`, and compute the version with `setuptools-scm` instead of `versioneer` [gh-2345](https://github.com/IntelPython/dpctl/pull/2345) |
There was a problem hiding this comment.
Nit: This line could also say what changes for developers: setup.py is gone (build with pip install ., add -e to develop), and build_locally.py --skip-editable now installs dpctl into the environment instead of building in place.
| - setuptools-scm >=8 | ||
| - cython-cmake >=0.2 | ||
| - cython >=3.1.0 # [py>=313] | ||
| - cython >=3.0.10 # [py<313] |
There was a problem hiding this comment.
Nit: CMake now requires Cython 3.1 (find_package(Cython MODULE REQUIRED VERSION 3.1)), so this could be cython >=3.1.0 for every Python, as in pyproject.toml.
| 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) |
There was a problem hiding this comment.
Nit: scikit-build's add_cython_target passed --gdb --line-directives for Debug and RelWithDebInfo builds; cython_transpile does not. So build_locally.py --debug now gives .cxx files without #line back to the .pyx, and gdb steps through generated C++. Appending these flags to CYTHON_ARGS for those build types would keep it.
| env=env, | ||
| cwd=setup_dir, | ||
| ) | ||
| cmd.append(f"--config-settings=cmake.args={';'.join(cmake_args)}") |
There was a problem hiding this comment.
Nit: scikit-build-core splits cmake.args on ; again, so a CMake list in --cmake-opts breaks: -DCMAKE_PREFIX_PATH=/opt/a;/opt/b reaches CMake as -DCMAKE_PREFIX_PATH=/opt/a and /opt/b. Passing the options in the CMAKE_ARGS environment variable, which is split on spaces, keeps them whole.
This PR proposes building dpctl instead with
scikit-build-core, upgrading fromscikit-buildto the more modern build system, and computing the version withsetuptools-scminstead ofversioneerIt includes the commits from gh-2388 (by @henryiii), rebased onto master, with the conda recipe, CHANGELOG and workflows adapted to the changes on master since; the examples are built with
scikit-build-coreas well, with a minimalpyproject.tomleach, anduse_dpctl_sycl_kernelinstalls its SPIR-V resources inside the packagescikit-build 1.0 broke the
setup.py build_extbuilds in CI; gh-2438 pins it below 1.0 until this PR is merged