Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ jobs:
retention-days: 7

build-wheels:
env:
# Skip rebuilding the CPU library when building the wheels.
BNB_SKIP_CMAKE: 1
needs:
- build-cpu
- build-cuda
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# Skip rebuilding the CPU library when installing the wheels.
# We build the libraries in separate jobs and upload as artifacts.
BNB_SKIP_CMAKE: 1

jobs:

build-cpu:
Expand Down Expand Up @@ -146,7 +151,7 @@ jobs:
- name: Install dependencies
run: |
pip install torch==${{ matrix.torch_version }} --index-url https://download.pytorch.org/whl/cpu
pip install -e ".[test]"
pip install -e ".[test]" -v
pip install pytest-cov

# We need to downgrade to numpy<2 for torch<2.4.1 compatibility on Windows
Expand Down Expand Up @@ -188,7 +193,7 @@ jobs:
- name: Install dependencies
run: |
pip install torch==2.7.1 --index-url https://download.pytorch.org/whl/cpu
pip install -e ".[test]"
pip install -e ".[test]" -v
pip install pytest-cov

- name: Show installed packages
Expand Down Expand Up @@ -263,7 +268,7 @@ jobs:

- name: Install dependencies
run: |
pip install -e ".[test]"
pip install -e ".[test]" -v
pip install pytest-cov

- name: Show installed packages
Expand Down Expand Up @@ -321,7 +326,7 @@ jobs:

- name: Install dependencies
run: |
pip install -e ".[test]"
pip install -e ".[test]" -v
pip install pytest-cov

- name: Show installed packages
Expand Down Expand Up @@ -438,7 +443,7 @@ jobs:
- name: Install dependencies
run: |
pip install --pre torch~=${{ matrix.torch_version }}.dev0 --index-url ${{ matrix.pypi_index }}
pip install -e ".[test]"
pip install -e ".[test]" -v
pip install pytest-cov
- name: Show installed packages
run: pip list
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "scipy.stats"
ignore_missing_imports = true

[tool.scikit-build]
cmake.build-type = "Release"
cmake.build-args = ["--config", "Release"]
wheel.cmake = false
44 changes: 26 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# 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
import os
from warnings import warn

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

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."
)
if os.environ.get("BNB_SKIP_CMAKE", "").lower() in ("1", "true", "yes"):
print("skipping CMake build")
else:
# 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.49.0.dev0",
packages=find_packages(),
distclass=BinaryDistribution,
cmake_source_dir=".",
cmdclass={
"build_py": ExtBuildPy,
},
)
cmdclass = {"build_py": ExtBuildPy}

setup_kwargs = {
"version": "0.49.0.dev0",
"packages": find_packages(),
"distclass": BinaryDistribution,
"cmdclass": {"build_py": ExtBuildPy},
}

if os.environ.get("BNB_SKIP_CMAKE", "").lower() not in ("1", "true", "yes"):
setup_kwargs["cmake_source_dir"] = "."

setup(**setup_kwargs)