Skip to content

Commit d1c2b0d

Browse files
CI: skip rebuilding CPU lib when building/installing wheels (#1803)
* CI: skip rebuilding CPU lib when building/installing wheels * CI: more verbosity when installing bitsandbytes
1 parent bcdc4de commit d1c2b0d

File tree

4 files changed

+44
-23
lines changed

4 files changed

+44
-23
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: 10 additions & 5 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:
@@ -146,7 +151,7 @@ jobs:
146151
- name: Install dependencies
147152
run: |
148153
pip install torch==${{ matrix.torch_version }} --index-url https://download.pytorch.org/whl/cpu
149-
pip install -e ".[test]"
154+
pip install -e ".[test]" -v
150155
pip install pytest-cov
151156
152157
# We need to downgrade to numpy<2 for torch<2.4.1 compatibility on Windows
@@ -188,7 +193,7 @@ jobs:
188193
- name: Install dependencies
189194
run: |
190195
pip install torch==2.7.1 --index-url https://download.pytorch.org/whl/cpu
191-
pip install -e ".[test]"
196+
pip install -e ".[test]" -v
192197
pip install pytest-cov
193198
194199
- name: Show installed packages
@@ -263,7 +268,7 @@ jobs:
263268

264269
- name: Install dependencies
265270
run: |
266-
pip install -e ".[test]"
271+
pip install -e ".[test]" -v
267272
pip install pytest-cov
268273
269274
- name: Show installed packages
@@ -321,7 +326,7 @@ jobs:
321326

322327
- name: Install dependencies
323328
run: |
324-
pip install -e ".[test]"
329+
pip install -e ".[test]" -v
325330
pip install pytest-cov
326331
327332
- name: Show installed packages
@@ -438,7 +443,7 @@ jobs:
438443
- name: Install dependencies
439444
run: |
440445
pip install --pre torch~=${{ matrix.torch_version }}.dev0 --index-url ${{ matrix.pypi_index }}
441-
pip install -e ".[test]"
446+
pip install -e ".[test]" -v
442447
pip install pytest-cov
443448
- name: Show installed packages
444449
run: pip list

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)