diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..00bdaa214 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include CMakeLists.txt +graft csrc +graft include diff --git a/pyproject.toml b/pyproject.toml index 6e5c6dde3..f575b5b66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/setup.py b/setup.py index 2f348ea2d..862e95897 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -12,4 +16,22 @@ def has_ext_modules(self): return True -setup(version="0.45.4.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.4.dev0", + packages=find_packages(), + distclass=BinaryDistribution, + cmake_source_dir=".", + cmdclass={ + "build_py": ExtBuildPy, + }) \ No newline at end of file