Skip to content

Move build system to meson-python#174

Open
ndgrigorian wants to merge 10 commits intomasterfrom
use-meson-build
Open

Move build system to meson-python#174
ndgrigorian wants to merge 10 commits intomasterfrom
use-meson-build

Conversation

@ndgrigorian
Copy link
Copy Markdown
Collaborator

@ndgrigorian ndgrigorian commented Apr 8, 2026

This PR proposes moving from setuptools to meson-python as the mkl-service build system

meson-python is already used by NumPy and allows setup.py to be removed (with its logic moved into the meson.build script)

Also adds mkl as a dependency

@ndgrigorian ndgrigorian marked this pull request as draft April 8, 2026 03:59
@ndgrigorian ndgrigorian force-pushed the use-meson-build branch 4 times, most recently from 1f7006a to e209e46 Compare April 8, 2026 06:35
@ndgrigorian ndgrigorian marked this pull request as ready for review April 8, 2026 06:51
Base automatically changed from drop-removed-cbwr-constants to master April 8, 2026 17:17
Copilot AI review requested due to automatic review settings April 8, 2026 18:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates mkl-service from a setuptools/setup.py-driven build to a meson-python build, updating conda recipes and CI workflows accordingly, and adding an mkl runtime dependency.

Changes:

  • Remove setup.py and define extension builds/install layout in meson.build (C + Cython extensions, Python sources, tests).
  • Switch pyproject.toml build backend to mesonpy and add mkl to runtime dependencies.
  • Update conda recipes and GitHub Actions workflows to build/install via pip/python -m build instead of setup.py.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
setup.py Removed legacy setuptools build script.
pyproject.toml Switched build backend to mesonpy, updated build requirements and runtime deps.
meson.build Added Meson build definition for C/Cython extensions and installation layout.
mkl/_py_mkl_service.pyx Added/introduced Cython wrapper implementation used by the public API.
conda-recipe/meta.yaml Updated conda build requirements for Meson-based builds.
conda-recipe/build.sh Updated wheel build/install flow (no setup.py).
conda-recipe/bld.bat Removed setup.py clean step and MKLROOT usage.
conda-recipe-cf/meta.yaml Updated conda-forge recipe host requirements for Meson-based builds.
conda-recipe-cf/build.sh Switched to pip install . build/install flow.
conda-recipe-cf/bld.bat Switched to pip install . build/install flow.
.github/workflows/build-with-standard-clang.yml New CI job building with system clang.
.github/workflows/build-with-clang.yml Updated IntelLLVM clang CI job to Meson-based install.
.github/workflows/build_pip.yml New CI job testing editable install + (pre-)release NumPy in conda env.

Comment thread pyproject.toml
Comment thread meson.build
'mkl-service',
['c', 'cython'],
version: run_command(
'python', '-c',
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

run_command('python', ...) hardcodes the interpreter, which may not match Meson’s discovered Python (virtualenv/pyenv/Windows). Use the py installation found by import('python').find_installation() when computing the version to avoid mismatched interpreters.

Suggested change
'python', '-c',
import('python').find_installation(pure: false), '-c',

Copilot uses AI. Check for mistakes.
Comment thread meson.build
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
numpy_version: ["numpy'>=2'"]
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The matrix value numpy_version: ["numpy'>=2'"] includes embedded quotes and will be passed verbatim to pip install, which is not a valid requirement specifier. Use something like numpy>=2 (or just install numpy and control pre-releases separately).

Suggested change
numpy_version: ["numpy'>=2'"]
numpy_version: ["numpy>=2"]

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/build-with-standard-clang.yml
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
numpy_version: ["numpy'>=2'"]
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The matrix value numpy_version: ["numpy'>=2'"] includes embedded quotes and will be passed verbatim to pip install, which is not a valid requirement specifier. Use something like numpy>=2.

Suggested change
numpy_version: ["numpy'>=2'"]
numpy_version: ["numpy>=2"]

Copilot uses AI. Check for mistakes.
Comment thread .github/workflows/build_pip.yml
@ndgrigorian ndgrigorian force-pushed the use-meson-build branch 2 times, most recently from 4a2979d to b3cd7c9 Compare April 10, 2026 00:33
Comment thread meson.build
@@ -0,0 +1,70 @@
project(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Might it be helpful to add meson.options?

Copy link
Copy Markdown
Collaborator Author

@ndgrigorian ndgrigorian Apr 24, 2026

Choose a reason for hiding this comment

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

It could, but I'm not sure if there's reason to add an empty one

I added an option in PR on top of this one
#184

Maybe I will think of others

Comment thread mkl/_py_mkl_service.pyx
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess we need to update AGENTS.md and copilot-instructions.md with that change

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And also to reflect there the new build command

Comment thread meson.build
@@ -0,0 +1,70 @@
project(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to add a section to the README.md or similar with the build instructions, when building from the source?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We should revise the build instructions but, in theory, python -m pip install . should still work

Comment thread conda-recipe-cf/meta.yaml
- mkl-devel
- cython
- wheel >=0.45.1
- python-build >=1.2.2
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Still used in conda-recipe/meta.yaml. Is that intended?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, it's used there because the build script there is more complicated and calls build command

conda-recipe-cf/build.sh just calls python -m pip install . --no-deps --no-build-isolation

Comment thread conda-recipe/meta.yaml
- {{ compiler('c') }}
- {{ stdlib('c') }}
host:
- meson-python >=0.13.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to parse pyproject.toml and to include the deps from there, as we currently do in dpnp/dpctl?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes, it probably does, though, I think it would be good for a follow up PR

Comment thread meson.build
)

rpath = ''
if host_machine.system() != 'windows'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it be better to be more explicit here? (since that will not work on macOS as well and probably others)

Suggested change
if host_machine.system() != 'windows'
if host_machine.system() == 'linux'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah that's a good idea

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.

3 participants