Skip to content

Commit 72b9129

Browse files
committed
Updating build system as scikit-build.
1 parent cbb3c37 commit 72b9129

File tree

14 files changed

+615
-1554
lines changed

14 files changed

+615
-1554
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Build (CPU)
22
on:
33
push:
44
branches: [master, dev]
5-
# release:
6-
# types: [published]
75

86
jobs:
97
build:
@@ -22,26 +20,14 @@ jobs:
2220
steps:
2321
- name: Check out repository code
2422
uses: actions/checkout@v4
25-
- name: Install Poetry
26-
run: |
27-
python -m pip install --upgrade pip
28-
python -m pip install poetry
2923
- name: Setup Python
3024
uses: actions/setup-python@v4
3125
with:
3226
python-version: ${{ matrix.version }}
33-
cache: "poetry"
34-
- name: Install dependencies
27+
- name: Install requirements
3528
run: |
36-
poetry install
29+
python -m pip install --upgrade pip
30+
python -m pip install numpy "pybind11[global]"
31+
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
3732
- name: Build
38-
run: |
39-
poetry install
40-
# - name: Check
41-
# run: poetry run python -c "import cshogi"
42-
# - name: Publish
43-
# if: github.event_name == 'release' && github.event.action == 'published'
44-
# env:
45-
# TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
46-
# TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
47-
# run: twine upload dist/*
33+
run: pip install .

.gitignore

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
build/*
2-
dist/*
3-
.vscode/*
4-
.mypy_cache/*
5-
6-
__pycache__
7-
*.pyd
8-
*.so
9-
*.egg-info
1+
build
2+
_skbuild
3+
dist
4+
.mypy_cache
5+
6+
__pycache__
7+
*.pyd
8+
*.so
9+
*.egg-info

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"flake8.path": "pflake8",
3+
"[python]": {
4+
"editor.formatOnSave": true,
5+
"editor.formatOnPaste": false,
6+
"editor.formatOnType": false,
7+
"editor.defaultFormatter": "eeyore.yapf",
8+
"editor.codeActionsOnSave": {
9+
"source.organizeImports": "always",
10+
}
11+
}
12+
}

CMakeLists.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
cmake_minimum_required(VERSION 3.15...3.27)
2+
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX)
3+
4+
# General settings
5+
set(BUILD_TARGET torchmcubes_module)
6+
7+
# CUDA settings
8+
include(CheckLanguage)
9+
check_language(CUDA)
10+
11+
if(CMAKE_CUDA_COMPILER)
12+
set(CMAKE_CUDA_ARCHITECTURES "native")
13+
enable_language(CUDA)
14+
15+
add_definitions(-DWITH_CUDA)
16+
find_package(CUDAToolkit REQUIRED)
17+
set(CMAKE_CUDA_STANDARD 17)
18+
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
19+
20+
message(STATUS "INSTALLING EXTENSIONS WITH CUDA!")
21+
string(REGEX REPLACE ".[0-9][0-9]|\\." "" CUDA_V ${CMAKE_CUDA_COMPILER_VERSION})
22+
message(STATUS "CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER}")
23+
message(STATUS "CMAKE_CUDA_COMPILER_ID = ${CMAKE_CUDA_COMPILER_ID}")
24+
message(STATUS "CMAKE_CUDA_COMPILER_VERSION = ${CUDA_V}")
25+
else()
26+
message(STATUS "NO CUDA INSTALLATION FOUND, INSTALLING CPU VERSION ONLY!")
27+
# execute_process(COMMAND ${Python_EXECUTABLE} -m pip uninstall -y torch)
28+
# execute_process(COMMAND ${Python_EXECUTABLE} -m pip install -v torch --extra-index-url https://download.pytorch.org/whl/cpu)
29+
endif()
30+
31+
set(CMAKE_CXX_STANDARD 17)
32+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
33+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
34+
35+
if(MSVC)
36+
add_definitions(-DNOMINMAX)
37+
endif()
38+
39+
# Find packages
40+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
41+
find_package(pybind11 CONFIG REQUIRED)
42+
43+
# OpenMP
44+
find_package(OpenMP)
45+
if (OPENMP_FOUND)
46+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
47+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
48+
endif()
49+
50+
# PyTorch settings
51+
find_package(Torch REQUIRED)
52+
find_library(TORCH_PYTHON_LIBRARY torch_python PATH "${TORCH_INSTALL_PREFIX}/lib")
53+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
54+
55+
add_subdirectory(cxx)
56+
57+
install(TARGETS ${BUILD_TARGET} LIBRARY DESTINATION .)

0 commit comments

Comments
 (0)