Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools >= 63.0.0"]
build-backend = "setuptools.build_meta"
requires = ["scikit-build-core", "setuptools >= 63.0.0"]
build-backend = "scikit_build_core.setuptools.build_meta"

[project]
name = "bitsandbytes"
Expand Down
24 changes: 23 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from distutils.errors import DistutilsModuleError
from warnings import warn

from setuptools import find_packages, setup
from setuptools.command.build_py import build_py
from setuptools.dist import Distribution


Expand All @@ -12,4 +16,22 @@ def has_ext_modules(self):
return True


setup(version="0.45.3.dev0", packages=find_packages(), distclass=BinaryDistribution)
class ExtBuildPy(build_py):
def run(self):
# build_cmake needs to be called prior to build_py, as the latter
# collects the files output into the package directory.
try:
self.run_command("build_cmake")
except DistutilsModuleError:
warn("scikit-build-core not installed, CMake will not be invoked automatically. "
"Please install scikit-build-core or run CMake manually to build extensions.")
super().run()


setup(version="0.45.3.dev0",
packages=find_packages(),
distclass=BinaryDistribution,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Technically, this is no longer necessary when CMake is called. However, since I preserved the support for using setup.py without scikit-build-core installed, I've left this hack in.

cmake_source_dir=".",
cmdclass={
"build_py": ExtBuildPy,
})