Skip to content

Commit 82754ab

Browse files
committed
Move to scikit-build-core
1 parent 430846c commit 82754ab

17 files changed

+168
-742
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ cython_test.cpp
2020
symengine/lib/symengine_wrapper.cpp
2121
symengine/lib/symengine_wrapper.pyx
2222
symengine/lib/symengine_wrapper.pxd
23+
symengine/_version.py
2324

2425
# Config Files
2526
symengine/lib/config.pxi
@@ -33,6 +34,12 @@ MANIFEST
3334
dist/
3435
.*cache/
3536
symengine.egg-info/
37+
.cmake/
38+
.ninja_deps
39+
.ninja_log
40+
.skbuild-info.json
41+
CMakeInit.txt
42+
symengine/lib/symengine_wrapper.cpp.dep
3643

3744
# Temp files
3845
*~

CMakeLists.txt

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 2.8.12...4.0.0)
1+
cmake_minimum_required(VERSION 3.21...4.0.0)
22

33
if (POLICY CMP0057)
44
cmake_policy(SET CMP0057 NEW) # needed for llvm >= 16
@@ -7,7 +7,7 @@ if (POLICY CMP0074)
77
cmake_policy(SET CMP0074 NEW) # allow user to set *_ROOT variables
88
endif()
99

10-
project(python_wrapper)
10+
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX)
1111

1212
set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH})
1313

@@ -21,13 +21,28 @@ set(CMAKE_BUILD_TYPE ${SYMENGINE_BUILD_TYPE})
2121
set(CMAKE_CXX_FLAGS_RELEASE ${SYMENGINE_CXX_FLAGS_RELEASE})
2222
set(CMAKE_CXX_FLAGS_DEBUG ${SYMENGINE_CXX_FLAGS_DEBUG})
2323
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SYMENGINE_CXX_FLAGS}")
24-
include_directories(${SYMENGINE_INCLUDE_DIRS})
2524

26-
set(WITH_PY_LIMITED_API OFF CACHE STRING "Use CPython's limited API")
27-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
28-
find_package(Python REQUIRED)
29-
find_package(Cython REQUIRED)
30-
include_directories(${PYTHON_INCLUDE_PATH})
25+
find_package(
26+
Python
27+
COMPONENTS
28+
Interpreter
29+
Development.Module
30+
${SKBUILD_SABI_COMPONENT}
31+
REQUIRED
32+
)
33+
34+
if ("${SKBUILD_SABI_VERSION}" STREQUAL "")
35+
set(CYTHON_MIN "0.29")
36+
else()
37+
set(CYTHON_MIN "3.1")
38+
endif()
39+
40+
find_package(Cython ${CYTHON_MIN} MODULE REQUIRED)
41+
include(UseCython)
42+
43+
if ("${CYTHON_VERSION}" VERSION_LESS "${CYTHON_MIN}")
44+
message(FATAL_ERROR "Cython version found: ${CYTHON_VERSION}. Minimum required: ${CYTHON_MIN}")
45+
endif()
3146

3247
if (MINGW AND ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8"))
3348
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DMS_WIN64")
@@ -56,7 +71,6 @@ foreach (PKG MPC MPFR PIRANHA FLINT LLVM)
5671
set(HAVE_SYMENGINE_${PKG} False)
5772
endif()
5873
endforeach()
59-
option(SYMENGINE_INSTALL_PY_FILES "Install python files" ON)
6074

6175
message("CMAKE_SYSTEM_PROCESSOR : ${CMAKE_SYSTEM_PROCESSOR}")
6276
message("CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}")
@@ -69,9 +83,5 @@ message("HAVE_SYMENGINE_PIRANHA : ${HAVE_SYMENGINE_PIRANHA}")
6983
message("HAVE_SYMENGINE_FLINT : ${HAVE_SYMENGINE_FLINT}")
7084
message("HAVE_SYMENGINE_LLVM : ${HAVE_SYMENGINE_LLVM}")
7185
message("HAVE_SYMENGINE_LLVM_LONG_DOUBLE : ${HAVE_SYMENGINE_LLVM_LONG_DOUBLE}")
72-
message("SYMENGINE_COPY_EXTENSION : ${SYMENGINE_COPY_EXTENSION}")
73-
74-
message("Copying source of python wrappers into: ${CMAKE_CURRENT_BINARY_DIR}")
75-
file(COPY symengine/ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/symengine)
7686

7787
add_subdirectory(symengine)

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ conda install python-symengine -c conda-forge
2727
Install prerequisites.
2828

2929
```bash
30-
CMake >= 2.8.12
31-
Python3 >= 3.8
32-
Cython >= 0.29.24
33-
SymEngine >= 0.7.0
30+
CMake >= 3.21
31+
Python3 >= 3.9
32+
SymEngine >= 0.14.0
33+
pip
34+
setuptools_scm # will be automatically downloaded by pip
35+
scikit-build-core # will be automatically downloaded by pip
36+
cython >= 0.29.24 # will be automatically downloaded by pip
37+
cython-cmake # will be automatically downloaded by pip
3438
```
3539

3640
For **SymEngine**, only a specific commit/tag (see `symengine_version.txt`) is
@@ -40,25 +44,22 @@ changes in **SymEngine**.
4044
Python wrappers can be installed by,
4145

4246
```bash
43-
python setup.py install
47+
pip install . -vv
4448
```
4549

46-
Additional options to `setup.py` are:
47-
50+
If you are building SymEngine for development, you should implement
51+
the dependencies automatically installed by pip and do,
4852
```bash
49-
python setup.py install build_ext
50-
--symengine-dir=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory
51-
--compiler=mingw32|msvc|cygwin # Select the compiler for Windows
52-
--generator=cmake-generator # CMake Generator
53-
--build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC
54-
--define="var1=value1;var2=value2" # Give options to CMake
55-
--inplace # Build the extension in source tree
53+
pip install -e . -vv --no-build-isolation
5654
```
5755

58-
Standard options to `setup.py` like `--user`, `--prefix` can be used to
59-
configure install location. NumPy is used if found by default, if you wish
60-
to make your choice of NumPy use explicit: then add
61-
e.g. `WITH_NUMPY=False` to `--define`.
56+
A few additional options to scikit-build-core are mentioned here:
57+
58+
```bash
59+
pip install -e . -vv --no-build-isolation
60+
-Ccmake.build-type=Release|Debug # Set build-type for multi-configuration generators like MSVC
61+
-Ccmake.define.SymEngine_DIR=/path/to/symengine/install/dir # Path to SymEngine install directory or build directory
62+
```
6263

6364
### Notes on Dependencies
6465

bin/install_travis.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# symengine's bin/install_travis.sh will install miniconda
44

5-
export conda_pkgs="python=${PYTHON_VERSION} pip pytest setuptools gmp mpfr"
5+
export conda_pkgs="python=${PYTHON_VERSION} pip pytest python-build scikit-build-core ninja cython-cmake cython setuptools-scm gmp mpfr"
66

77
if [[ "${WITH_NUMPY}" != "no" ]]; then
88
export conda_pkgs="${conda_pkgs} numpy";
@@ -31,7 +31,7 @@ if [[ "${WITH_SAGE}" == "yes" ]]; then
3131
export conda_pkgs="${conda_pkgs} sage=8.1";
3232
fi
3333

34-
conda install -q ${conda_pkgs} "cython>=0.29.24"
34+
conda install -q ${conda_pkgs}
3535

3636
if [[ "${WITH_SYMPY}" != "no" ]]; then
3737
pip install sympy;

bin/test_travis.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ set -e
55
# Echo each command
66
set -x
77

8-
python setup.py sdist
8+
python -m build . --sdist
99
mkdir dist-extract
1010
cd dist-extract
1111
tar -xvf ../dist/symengine-*.tar.gz
1212
cd symengine-*
1313

14-
# Build inplace so that nosetests can be run inside source directory
15-
python3 setup.py install build_ext --inplace --symengine-dir=$our_install_dir
16-
17-
if [[ "${SYMENGINE_PY_LIMITED_API:-}" != "" ]]; then
14+
# Build inplace
15+
if [[ "${SYMENGINE_PY_LIMITED_API:-}" == "" ]]; then
16+
python3 -m pip install -e . -vv -Ccmake.define.SymEngine_DIR=$our_install_dir
17+
else
18+
python3 -m pip install -e . -vv -Ccmake.define.SymEngine_DIR=$our_install_dir -Cwheel.py-api="cp${SYMENGINE_PY_LIMITED_API/./}"
1819
python3 -m abi3audit --assume-minimum-abi3 ${SYMENGINE_PY_LIMITED_API} symengine/lib/symengine_wrapper.abi3.so -v
1920
fi
2021

cmake/FindCython.cmake

Lines changed: 0 additions & 93 deletions
This file was deleted.

cmake/FindNumPy.cmake

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)