Skip to content

Feat/enable free threaded python#213

Open
vchamarthi wants to merge 4 commits into
IntelPython:masterfrom
vchamarthi:feat/enable-free-threaded-python
Open

Feat/enable free threaded python#213
vchamarthi wants to merge 4 commits into
IntelPython:masterfrom
vchamarthi:feat/enable-free-threaded-python

Conversation

@vchamarthi

Copy link
Copy Markdown

This PR might look weird until meson python PR is merged

The latest commit adds the Free threading support for mkl-service

Copilot AI review requested due to automatic review settings June 23, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown

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 adds initial support for CPython’s free-threaded (GIL-disabled) builds in mkl-service, and (as a prerequisite / in anticipation of PR #174) migrates the build and packaging flow from setuptools/setup.py to meson-python across pip/CI/conda recipes.

Changes:

  • Enable free-threading compatibility in the Cython extension and declare the _mklinit C extension as GIL-independent for free-threaded interpreters.
  • Switch to meson-python (meson.build, pyproject.toml) and remove setup.py.
  • Update CI workflows and conda recipes to build via PEP 517 / Meson and expand Python coverage to 3.14.

Reviewed changes

Copilot reviewed 19 out of 19 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 Switch build backend to mesonpy and update build requirements.
meson.build New Meson build defining _mklinit and _py_mkl_service extension builds and install layout.
mkl/_py_mkl_service.pyx Mark Cython extension as free-threading compatible.
mkl/_mklinitmodule.c Declare module GIL usage as “not used” on free-threaded builds.
README.md Add source build instructions for Meson/PEP517 flow.
AGENTS.md Update repo-level build/CI documentation to Meson + new workflows.
mkl/AGENTS.md Update Cython wrapper file naming references.
.github/workflows/build-with-clang.yml Update CI build steps for Meson/PEP517 and Python 3.14.
.github/workflows/build-with-standard-clang.yml New workflow to build/test with system clang.
.github/workflows/build_pip.yml New workflow to validate pip editable build + tests via conda env.
conda-recipe/meta.yaml Update host deps for Meson/PEP517 and remove python-gil constraints.
conda-recipe/build.sh Build via python -m build instead of setup.py; clean build dir.
conda-recipe/bld.bat Build via python -m build instead of setup.py.
conda-recipe-cf/meta.yaml Update host deps for Meson/PEP517 and remove python-gil constraints.
conda-recipe-cf/build.sh Build/install via pip (PEP517) instead of setup.py.
conda-recipe-cf/bld.bat Build/install via pip (PEP517) instead of setup.py.
.github/copilot-instructions.md Update API-contract file reference to _py_mkl_service.pyx.
.github/AGENTS.md Document newly added workflows.
Comments suppressed due to low confidence (1)

mkl/_py_mkl_service.pyx:28

  • Free-threading support is being enabled here, but there’s no corresponding test ensuring the package imports/operates correctly under a free-threaded (GIL-disabled) Python build (e.g., that importing mkl does not re-enable the GIL and basic API calls still work). Adding a small conditional test in mkl/tests/test_mkl_service.py would help prevent regressions.

Comment thread README.md Outdated
Comment thread AGENTS.md Outdated
Comment thread .github/copilot-instructions.md
Comment thread meson.build
Comment thread .github/workflows/build-with-standard-clang.yml
Comment thread .github/workflows/build_pip.yml Outdated
Comment thread .github/workflows/build_pip.yml Outdated
@vchamarthi

Copy link
Copy Markdown
Author

the copilot review comments are basically on the meson python PR #174
This will be cleanly reviewed after it gets meged.

@antonwolfy antonwolfy added this to the 2.9.0 release milestone Jul 24, 2026
- name: Install mkl-service dependencies
run: |
pip install meson-python cython cmake ninja
pip install meson-python "cython>=3.1.0" cmake ninja

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.

Could you please add to the PR description, why we need to limit cython version?

Comment thread conda-recipe/meta.yaml
- cmake
- ninja
- python
- python-build

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.

Why there is no need to have >=1.2.2 anymore?

- name: Install mkl-service dependencies
run: |
pip install meson-python cython cmake ninja
pip install meson-python "cython>=3.1.0" cmake ninja

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 update Build dependencies in AGENTS.md to state Cython 3.1+ is required?

@@ -55,7 +55,7 @@ jobs:

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.

Need to populate changelog

Comment thread conda-recipe/meta.yaml
- ninja
- python
- python-build
- python-gil # [py>=314]

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.

Why did we keep python-gil here but removed in cf receipe?

Comment thread pyproject.toml
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",

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.

missed to declare the support in metadata:

Suggested change
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Free Threading :: 2 - Beta",

@@ -55,7 +55,7 @@ jobs:

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.

Need to extend strategy matrix for GitHub workflows to validate 3.14t also

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