Replies: 6 comments 31 replies
|
Split mode is certainly helpful; previously I've rejected using the stable ABI, not wanting to pay performance costs. A few questions that occurred to me when I read the docs that I think might be worth adding to the docs:
I think it's likely I will use this mode for many but perhaps not all of my extension modules. |
|
Nice work! I'm a bit behind on the Bazel distribution side, although I have not heard of any remaining users of Other than that, I think the Bazel user base is largely going the module extension route, which makes sense since nanobind is a very lightweight dependency. Maybe it's worth documenting that setup instead of publishing opinionated Bazel builds to the BCR that don't fit anyone's needs 100%. I'm curious about other opinions. |
|
Another thing I noticed: abi3t support requires split mode. That is unfortunate if one cannot use split mode for the reasons above... |
|
One issue I noticed while testing nanobind 3 split mode with MLX is its interaction with the CPython buffer protocol. Nanobind’s split-mode frontend targets the Python 3.10 Stable ABI and defines MLX implements the buffer protocol for This appears to prevent MLX from using the stock split-mode configuration to publish a single Is there a recommended solution for custom buffer-protocol exporters in split mode? For example, could split mode support a configurable Stable ABI floor such as Nanobind’s own Is there another supported approach that I may be missing? |
|
I haven't had time to look at this "split" mode yet, but one random thought occurred to me: version 2.2.0 (October 3, 2024) mentioned
So, can we remove it? [I just like removing code. 😉] |
|
One additional packaging issue came up while testing MLX on Python 3.13t and 3.14t. Regular wheels use split mode, and MLX generates stubs during the wheel build by importing mlx.core, so This cannot currently be expressed in regular requires before building, cause environment markers do not expose whether python is free-threaded, 3.13 and 3.13t have the same python_version. install_requires is also too late for the stub-generation import. My current workaround is a wrapper around _build_backend/backend.py import os
import sysconfig
from setuptools import build_meta as _setuptools_build_meta
from setuptools.build_meta import * # type: ignore # noqa: F403
def _with_nanobind_backend(requires):
build_backend = int(os.environ.get("MLX_BUILD_BACKEND_PACKAGE", 0))
free_threaded = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
if not build_backend and not free_threaded:
requires.append("nanobind-backend>=1.0.0.dev2")
return requires
def get_requires_for_build_wheel(config_settings=None):
requires = _setuptools_build_meta.get_requires_for_build_wheel(config_settings)
return _with_nanobind_backend(requires)
def get_requires_for_build_editable(config_settings=None):
requires = _setuptools_build_meta.get_requires_for_build_editable(config_settings)
return _with_nanobind_backend(requires)pyproject.toml [build-system]
requires = [
"setuptools>=80",
"cmake>=3.26",
"typing_extensions",
]
build-backend = "backend"
backend-path = ["_build_backend"] |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone!
I've just released a development prerelease of nanobind 3.0.0, which introduces a new distribution model called "split mode". I think that this could be quite appealing to some projects that suffer from having to distribute many Python wheels. You can read about it here.
It would be great if you could test your projects with this split mode and let me know if you encounter any issues before I make a full release. This is a discussion thread about anything related to the new release.
I am especially curious to hear from some of the heavy users of nanobind: @zcbenz @awni @hawkinsp @XXXXRT666 @oremanj.
Another thing worth noting is that other build system adapters for Bazel and Meson will need changes to support split mode. (cc @nicholasjng, @WillAyd).
That's all for now.
Thanks,
Wenzel
All reactions