Skip to content

Commit

Permalink
build fixes, dist updates, auto-detect CUDA arch
Browse files Browse the repository at this point in the history
- replaces/closes #31
  • Loading branch information
casperdcl committed Dec 8, 2023
1 parent 18a2cda commit dafd9b7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
43 changes: 25 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,23 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: pip install -U -e .[dev]
env:
# https://github.com/scikit-build/scikit-build/issues/740
SETUPTOOLS_ENABLE_FEATURES: legacy-editable
- name: pip install -U -e .[dev]
# in-place for pytest (-e . doesn't work yet for scikit-build-core)
run: |
pip install toml
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["build-system"]["requires"]), end="")' \
| xargs -0 pip install
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["project"]["optional-dependencies"]["dev"]), end="")' \
| xargs -0 pip install
pip install --no-build-isolation --no-deps -t . -U -v . -Ccmake.define.CUVEC_DEBUG=1
git restore cuvec/src
- run: pytest
- uses: codecov/codecov-action@v3
- name: compile -Wall
run: |
git clean -Xdf
pip install toml
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["build-system"]["requires"]), end="")' \
| xargs -0 pip install
python setup.py build -- -DCUVEC_DEBUG=1 \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-function-type"
python -m build -n -w \
-Ccmake.define.CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-function-type"
cuda:
if: github.event_name != 'pull_request' || !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
name: CUDA py${{ matrix.python }}
Expand All @@ -80,20 +83,24 @@ jobs:
fetch-depth: 0
- name: Run setup-python
run: setup-python -p${{ matrix.python }} 'cuda-version<12' cupy
- run: pip install -U -e .[dev]
env:
# https://github.com/scikit-build/scikit-build/issues/740
SETUPTOOLS_ENABLE_FEATURES: legacy-editable
- name: pip install -U -e .[dev]
# in-place for pytest (-e . doesn't work yet for scikit-build-core)
run: |
pip install toml
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["build-system"]["requires"]), end="")' \
| xargs -0 pip install
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["project"]["optional-dependencies"]["dev"]), end="")' \
| xargs -0 pip install
pip install --no-build-isolation --no-deps -t . -U -v . -Ccmake.define.CUVEC_DEBUG=1
git restore cuvec/src
- run: pytest
- uses: codecov/codecov-action@v3
- name: compile -Wall
run: |
git clean -Xdf
pip install toml
python -c 'import toml; c=toml.load("pyproject.toml"); print("\0".join(c["build-system"]["requires"]), end="")' \
| xargs -0 pip install
python setup.py build -- -DCUVEC_DEBUG=1 \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-function-type"
python -m build -n -w \
-Ccmake.define.CMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-function-type" \
-Ccmake.define.CMAKE_CUDA_ARCHITECTURES=all
- name: Post Run setup-python
run: setup-python -p${{ matrix.python }} -Dr
if: ${{ always() }}
Expand Down
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ __pycache__/

# build
*.so
CMakeFiles/
cmake_install.cmake
/cuvec/*.ninja*
/cuvec/AMYPADcuvecConfig*.cmake
/cuvec/CMakeCache.txt
/cuvec/CMakeInit.txt
/cuvec/_dist_ver.py
/cuvec/cmake/
/cuvec-*.dist-info/
/cuvec/*PYTHON_wrap.cxx
/cuvec/example_swig.py
/cuvec/swvec.py
/build/
/dist/
/docs/build/

Expand Down
9 changes: 6 additions & 3 deletions cuvec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
if("${SKBUILD_PROJECT_VERSION}" STREQUAL "")
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
if(NOT DEFINED SKBUILD_PROJECT_VERSION)
set(SKBUILD_PROJECT_VERSION 2 CACHE STRING "version" FORCE)
endif()
string(REGEX REPLACE [[([0-9]+)\.([0-9]+)\.([0-9]+).*]] [[\1.\2.\3]] SKBUILD_PROJECT_VERSION "${SKBUILD_PROJECT_VERSION}")
Expand All @@ -9,6 +9,9 @@ option(CUVEC_CUDA_OPTIONAL "Make CUDA optional rather than forced" ON)

cmake_policy(PUSH)
cmake_policy(SET CMP0074 NEW) # <PackageName>_ROOT hints for find_package
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES native CACHE STRING "CUDA arch" FORCE)
endif()
cmake_policy(SET CMP0104 NEW) # CMAKE_CUDA_ARCHITECTURES
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) # NumPy
if(NOT CUVEC_CUDA_OPTIONAL)
Expand Down Expand Up @@ -38,7 +41,7 @@ endif()
cmake_policy(POP)

message(STATUS "CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ build-backend = "scikit_build_core.build"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["cuvec/_dist_ver.py"]
sdist.exclude = ["docs", "tests", ".*"]
wheel.exclude = ["cuvec/src/**"]
minimum-version = "0.5"
cmake.minimum-version = "3.18"
cmake.minimum-version = "3.24"
cmake.source-dir = "cuvec"

[tool.setuptools_scm]
Expand Down

0 comments on commit dafd9b7

Please sign in to comment.