Skip to content

Commit 185180a

Browse files
CI: skip rebuilding CPU lib when building/installing wheels
1 parent bcdc4de commit 185180a

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ jobs:
171171
retention-days: 7
172172

173173
build-wheels:
174+
env:
175+
# Skip rebuilding the CPU library when building the wheels.
176+
BNB_SKIP_CMAKE: 1
174177
needs:
175178
- build-cpu
176179
- build-cuda

.github/workflows/tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ concurrency:
1010
group: ${{ github.workflow }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
env:
14+
# Skip rebuilding the CPU library when installing the wheels.
15+
# We build the libraries in separate jobs and upload as artifacts.
16+
BNB_SKIP_CMAKE: 1
17+
1318
jobs:
1419

1520
build-cpu:

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,8 @@ ignore_missing_imports = true
163163
[[tool.mypy.overrides]]
164164
module = "scipy.stats"
165165
ignore_missing_imports = true
166+
167+
[tool.scikit-build]
168+
cmake.build-type = "Release"
169+
cmake.build-args = ["--config", "Release"]
170+
wheel.cmake = false

setup.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# This source code is licensed under the MIT license found in the
44
# LICENSE file in the root directory of this source tree.
55
from distutils.errors import DistutilsModuleError
6+
import os
67
from warnings import warn
78

89
from setuptools import find_packages, setup
@@ -18,24 +19,31 @@ def has_ext_modules(self):
1819

1920
class ExtBuildPy(build_py):
2021
def run(self):
21-
# build_cmake needs to be called prior to build_py, as the latter
22-
# collects the files output into the package directory.
23-
try:
24-
self.run_command("build_cmake")
25-
except DistutilsModuleError:
26-
warn(
27-
"scikit-build-core not installed, CMake will not be invoked automatically. "
28-
"Please install scikit-build-core or run CMake manually to build extensions."
29-
)
22+
if os.environ.get("BNB_SKIP_CMAKE", "").lower() in ("1", "true", "yes"):
23+
print("skipping CMake build")
24+
else:
25+
# build_cmake needs to be called prior to build_py, as the latter
26+
# collects the files output into the package directory.
27+
try:
28+
self.run_command("build_cmake")
29+
except DistutilsModuleError:
30+
warn(
31+
"scikit-build-core not installed, CMake will not be invoked automatically. "
32+
"Please install scikit-build-core or run CMake manually to build extensions."
33+
)
3034
super().run()
3135

3236

33-
setup(
34-
version="0.49.0.dev0",
35-
packages=find_packages(),
36-
distclass=BinaryDistribution,
37-
cmake_source_dir=".",
38-
cmdclass={
39-
"build_py": ExtBuildPy,
40-
},
41-
)
37+
cmdclass = {"build_py": ExtBuildPy}
38+
39+
setup_kwargs = {
40+
"version": "0.49.0.dev0",
41+
"packages": find_packages(),
42+
"distclass": BinaryDistribution,
43+
"cmdclass": {"build_py": ExtBuildPy},
44+
}
45+
46+
if os.environ.get("BNB_SKIP_CMAKE", "").lower() not in ("1", "true", "yes"):
47+
setup_kwargs["cmake_source_dir"] = "."
48+
49+
setup(**setup_kwargs)

0 commit comments

Comments
 (0)