Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use scikit-build-core #755

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

matthiasdiener
Copy link
Contributor

@matthiasdiener matthiasdiener commented May 10, 2024

This appears to fix #753.

TODO:

Please squash

@alexfikl
Copy link
Contributor

If we want to switch, why not meson-python instead? The numpy / scipy / matplotlib ecosystem seems to have gone that way and it's probably a good idea to follow..

@matthiasdiener
Copy link
Contributor Author

If we want to switch, why not meson-python instead? The numpy / scipy / matplotlib ecosystem seems to have gone that way and it's probably a good idea to follow..

TIL, thanks! I think the main reason for using scikit-build-core is that it is what nanobind recommends, and it's used in their examples.

@matthiasdiener
Copy link
Contributor Author

This seems to work fine and is ready for a first look @inducer. I'm not sure what the best way to replace/reimplement the configure.py functionality is.

@alexfikl
Copy link
Contributor

This seems to work fine and is ready for a first look @inducer. I'm not sure what the best way to replace/reimplement the configure.py functionality is.

What functionality exactly? Generally the configuration can be done in CMakeLists.txt and you can pass it arguments using

pip install . --config-settings='cmake.args=-DSOME_DEFINE=ON;-DOTHER=OFF'

pyproject.toml Outdated
Comment on lines 11 to 16
PYOPENCL_TRACE = {env="CL_TRACE", default="OFF"}
PYOPENCL_ENABLE_GL = {env="CL_ENABLE_GL", default="OFF"}
PYOPENCL_USE_SHIPPED_EXT = {env="CL_USE_SHIPPED_EXT", default="OFF"}
OpenCL_INCLUDE_DIR = {env="CL_INC_DIR"}
PYOPENCL_CL_LIB_DIRS = {env="CL_LIB_DIR"}
OpenCL_LIBRARY = {env="CL_LIBNAME"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also be defined in CMakeLists.txt as option(PYOPENCL_TRACE "Enable tracing functionality" OFF)? At least that's idiomatic from what I recall..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 34a47d9

Comment on lines +47 to +49
export CL_INC_DIR="$CONDA_PREFIX/include"
export CL_LIB_DIR="$CONDA_PREFIX/lib"
export CL_LIBNAME=OpenCL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this logic be in CMakeLists.txt? Something like if($ENV{CONDA_PREFIX}) set(CL_INC_DIR "${CONDA_PREFIX}/include")?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, it feels a bit strange for the CMakeLists.txt file to know about conda.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but maybe the logic could be made conditional on there being an OpenCL library in the conda env? If there is, I think there is an overwhelming likelihood it should be used. And PyOpenCL's documentation talks about conda as a means to install, so it's not like the two projects are totally unrelated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, on my system (cmake 3.29.3) there are a few cmake modules that look at CONDA_PREFIX in particular: GNUInstallDirs.cmake, UnixPaths.cmake and FindPython/Support.cmake.

So I don't think there's anything strange about teaching the build a bit more about the platform, which in this case is conda.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, looking at FindOpenCL.cmake, it seems like we can set OCL_ROOT=$CONDA_PREFIX to let it find the right folders itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, thanks. conda support was added in 9b3c600

@matthiasdiener
Copy link
Contributor Author

What functionality exactly? Generally the configuration can be done in CMakeLists.txt and you can pass it arguments using

More specifically, I meant an easy-ish way for the user to configure the build, similar to the configure.py / siteconf.py system in the current version.

pip install . --config-settings='cmake.args=-DSOME_DEFINE=ON;-DOTHER=OFF'

Yeah, that is an option for replacing configure.py. Additionally, I was thinking of providing a siteconf.cmake file similar to siteconf.py.

@inducer
Copy link
Owner

inducer commented May 17, 2024

I think ditching the configure.py mechanism is the right approach at this point. As long as we document the cmake.args way (also maybe add an entry to the changelog), I think that's OK.

@matthiasdiener
Copy link
Contributor Author

matthiasdiener commented May 20, 2024

Here are the OpenCL config options that we have been discussing (all except nr. 4 should work with the current state of this PR):

  1. Get path from CONDA_PREFIX if set
  2. siteconf.cmake
  3. Environment variables
  4. Having some kind of configure.py-like frontend (that calls pip install with the right options?)
  5. pip install . --config-settings='cmake.args=-D....'
  6. Fallback: let's just have cmake try to find OpenCL

If I understood correctly, option 4 isn't really desired. Are there any other options we should add/remove? (e.g., perhaps sieconf.cmake isn't necessary?)

Besides the question above, this is ready for a second look (in particular, regarding the next steps).

@matthiasdiener matthiasdiener marked this pull request as ready for review May 21, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip install . causes messy directory layout
3 participants