Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate to scikit-build-core #202

Merged
merged 14 commits into from
Apr 20, 2024
Merged
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ repos:
hooks:
- id: cython-lint
- id: double-quote-cython-strings
# CMake
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.26...3.28)
project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)

find_package(
Python
COMPONENTS Interpreter Development.SABIModule
REQUIRED)

add_custom_command(
OUTPUT dps.cpp
COMMENT
"Making ${CMAKE_CURRENT_BINARY_DIR}/dps.cpp from ${CMAKE_CURRENT_SOURCE_DIR}/mddatasetbuilder/dps.pyx"
COMMAND
Python::Interpreter -m cython
"${CMAKE_CURRENT_SOURCE_DIR}/mddatasetbuilder/dps.pyx" --output-file dps.cpp
DEPENDS mddatasetbuilder/dps.pyx
VERBATIM)

python_add_library(
dps
MODULE
USE_SABI
3.7
${CMAKE_CURRENT_BINARY_DIR}/dps.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mddatasetbuilder/c_stack.cpp
WITH_SOABI)
target_include_directories(dps
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/mddatasetbuilder)
target_compile_definitions(dps PRIVATE CYTHON_LIMITED_API=1)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(dps PRIVATE CYTHON_TRACE=1 CYTHON_TRACE_NOGIL=1)
endif()

install(TARGETS dps DESTINATION mddatasetbuilder/)
2 changes: 0 additions & 2 deletions mddatasetbuilder/c_stack.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
extern "C" {
#include "c_stack.h"
}

C_Stack::C_Stack() {
tail = new Node;
Expand Down
2 changes: 0 additions & 2 deletions mddatasetbuilder/c_stack.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <Python.h>

extern "C" {
class C_Stack {
private:
struct Node {
Expand All @@ -18,4 +17,3 @@ class C_Stack {

int pop();
};
}
17 changes: 12 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[build-system]
requires = ["setuptools>=61", "setuptools_scm[toml]>=7", "cython>=3.0.1", "wheel"]
build-backend = "setuptools.build_meta"
requires = [
"scikit-build-core>=0.9.0",
"cython>=3.0.1",
]
build-backend = "scikit_build_core.build"

[project]
name = "mddatasetbuilder"
Expand Down Expand Up @@ -43,7 +46,7 @@ homepage = "https://github.com/tongzhugroup/mddatasetbuilder"
documentation = "https://mddatasetbuilder.njzjz.win/"
repository = "https://github.com/tongzhugroup/mddatasetbuilder"

[project.entry-points.console_scripts]
[project.scripts]
datasetbuilder = "mddatasetbuilder.datasetbuilder:_commandline"
qmcalc = "mddatasetbuilder.qmcalc:_commandline"
preparedeepmd = "mddatasetbuilder.deepmd:_commandline"
Expand All @@ -57,8 +60,12 @@ test = [
'fakegaussian>=0.0.3',
]

[tool.setuptools.packages.find]
include = ["mddatasetbuilder*"]
[tool.scikit-build]
minimum-version = "0.9"
wheel.py-api = "cp37"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["mddatasetbuilder/_version.py"]
cmake.version = ">=3.26"

[tool.setuptools_scm]
write_to = "mddatasetbuilder/_version.py"
Expand Down
39 changes: 0 additions & 39 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ passenv =
TOXENV
GITHUB_*
setenv =
DEBUG = 1
SKBUILD_CMAKE_BUILD_TYPE = Debug
usedevelop = true
commands =
pytest tests --cov --cov-report term --cov-report xml --cov-config={toxinidir}/tox.ini
Expand Down
Loading