Skip to content

Commit

Permalink
Modernize the build system with scikit-build-core
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhbell committed Nov 15, 2024
1 parent dedc38a commit 278c580
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 115 deletions.
19 changes: 16 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,21 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/externals/autodiff")
# Turn on more useful diagnostic messages in nlohmann::json, for instance if you are accessing a field that doesn't exist
set(JSON_Diagnostics TRUE CACHE BOOL "Turn on more helpful diagnostics in nlohmann::json")




# Single-source the version, either from scikit, or from parsing the pyproject.toml
if (SKBUILD)
add_definitions("-DTEQPVERSION=\"${SKBUILD_PROJECT_VERSION_FULL}\"")
else()
file(READ "pyproject.toml" TOML_CONTENT)
set(REG "version = \"([0-9]+\\.[0-9]+\\.[0-9]+)\"")
string(REGEX MATCH "${REG}" VERSION_MATCH "${TOML_CONTENT}")
if (NOT VERSION_MATCH)
message(FATAL_ERROR "Can't parse the version")
else()
string(REGEX REPLACE "${REG}" "\\1" PROJECT_VERSION_FULL "${VERSION_MATCH}")
message(STATUS "Version: ${PROJECT_VERSION_FULL}")
add_definitions("-DTEQPVERSION=\"${PROJECT_VERSION_FULL}\"")
endif()
endif()

if (NOT TEQP_NO_TEQPCPP)
# Add a static library with the C++ interface that uses only STL
Expand Down Expand Up @@ -240,6 +252,7 @@ if (NOT TEQP_NO_PYTHON)
if (MSVC)
target_compile_options(teqp PRIVATE "/Zm1000")
endif()
install(TARGETS teqp LIBRARY DESTINATION teqp)
endif()

if (NOT TEQP_NO_TESTS)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,9 @@ cmake --build . --target multifluid_crit

* When building in WSL via VS Code, you might need to enable metadata to avoid pages of configure errors in cmake: https://github.com/microsoft/WSL/issues/4257
* Debugging in WSL via VS Code (it really works!): https://code.visualstudio.com/docs/cpp/config-wsl
* Incremental rebuilds:

* See https://nanobind.readthedocs.io/en/latest/packaging.html#step-5-incremental-rebuilds ::

pip install scikit-build-core[pyproject]
pip install --no-build-isolation -ve .
1 change: 0 additions & 1 deletion interface/pybind11_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <pybind11/stl.h>
#include <pybind11/eigen.h>

#include "teqpversion.hpp"
#include "teqp/ideal_eosterms.hpp"
#include "teqp/cpp/derivs.hpp"
#include "teqp/derivs.hpp"
Expand Down
2 changes: 0 additions & 2 deletions interface/teqpversion.hpp

This file was deleted.

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,46 @@
select = "*-musllinux*"
before-all = "apk add clang"
environment = { CXX="clang++" }

[build-system]
requires = ["scikit-build-core >=0.4.3", "pybind11 >=2.13", "typing_extensions"]
build-backend = "scikit_build_core.build"

[project]
name = "teqp"
version = "0.23.0"
description = "teqp: Templated EQuation of state Package"
readme = "README.md"
requires-python = ">=3.8"
authors = [
{ name = "Ian Bell", email = "[email protected]" },
]
#classifiers = [
# "License :: BSD",
#]

[project.urls]
Homepage = "https://github.com/usnistgov/teqp"

[tool.scikit-build]
# Protect the configuration against future changes in scikit-build-core
minimum-version = "0.10"

# Setuptools-style build caching in a local directory
build-dir = "build/{wheel_tag}"

# The package to be built is that in the teqp folder
wheel.packages = ["teqp"]
build.targets = ["teqp"]

# Build stable ABI wheels for CPython 3.12+
# wheel.py-api = "cp312"

#### Additional options for debugging
# cmake.verbose = true
# cmake.build-type = "Debug"
# cmake.args = ["-G Xcode", "-DXCODE_DEBUG_PYTHON=ON"]
# cmake.args = ["-DVERBOSE=ON"]

[tool.cibuildwheel]
build-verbosity = 1
109 changes: 0 additions & 109 deletions setup.py

This file was deleted.

0 comments on commit 278c580

Please sign in to comment.