Skip to content

Commit 54f99cf

Browse files
authored
Merge pull request #523 from isuruf/skbuild
Move to scikit-build-core
2 parents 430846c + f3638c9 commit 54f99cf

18 files changed

+199
-796
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

appveyor.yml

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ environment:
3838
PYTHON_VERSION: 311-x64
3939
WITH_NUMPY: no
4040
CONDA_INSTALL_LOCN: C:\\Miniconda38-x64
41-
#- BUILD_TYPE: "Debug"
42-
# COMPILER: MinGW-w64
43-
# PYTHON_VERSION: 39-x64
44-
# WITH_NUMPY: no
45-
#- BUILD_TYPE: "Release"
46-
# COMPILER: MinGW-w64
47-
# PYTHON_VERSION: 39-x64
48-
#- BUILD_TYPE: "Debug"
49-
# COMPILER: MinGW-w64
50-
# PYTHON_VERSION: 39-x64
51-
# WITH_SYMPY: no
5241
- BUILD_TYPE: "Release"
5342
COMPILER: MSVC15
5443
PLATFORM: "x64"
@@ -63,41 +52,23 @@ install:
6352
- git clone https://github.com/sympy/symengine symengine-cpp
6453
- if [%PLATFORM%]==[Win32] set "CONDA_SUBDIR=win-32"
6554

66-
- if [%COMPILER%]==[MSVC15] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
67-
- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=mpir=3.0.0 vc=14"
68-
- if [%COMPILER%]==[MSVC15] if [%WITH_MPFR%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpfr=3.1.5"
69-
- if [%COMPILER%]==[MSVC15] if [%WITH_MPC%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpc=1.0.3"
70-
- if [%COMPILER%]==[MSVC15] if [%WITH_LLVM%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% llvmdev=4.0"
71-
- if [%COMPILER%]==[MSVC15] set "CONDA_DEPS=%CONDA_DEPS% -c conda-forge"
72-
- if [%COMPILER%]==[MSVC15] if [%BUILD_TYPE%]==[Debug] set "CONDA_DEPS=%CONDA_DEPS% -c symengine/label/debug"
73-
- if [%COMPILER%]==[MSVC15] conda create -n deps --yes %CONDA_DEPS%
74-
- if [%COMPILER%]==[MSVC15] call conda activate deps
75-
- if [%COMPILER%]==[MSVC15] echo %CONDA_PREFIX%
76-
- if [%COMPILER%]==[MSVC15] echo %PATH%
77-
- if [%COMPILER%]==[MSVC15] set "PATH=%PATH%;%CONDA_PREFIX%\\Library\\bin;%CONDA_PREFIX%"
78-
- if [%COMPILER%]==[MSVC15] echo %PATH%
79-
80-
- if [%COMPILER%]==[MinGW] set "PATH=C:\MinGW\bin;%PATH%"
81-
- if [%COMPILER%]==[MinGW] mingw-get update
82-
# workaround for https://github.com/appveyor/ci/issues/996
83-
- if [%COMPILER%]==[MinGW] mingw-get upgrade mingw32-libstdc++
84-
- if [%COMPILER%]==[MinGW] mingw-get install mingw32-gmp
85-
86-
- if [%COMPILER%]==[MinGW-w64] set "PATH=C:\mingw64\bin;%PATH%"
87-
88-
- rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
89-
90-
- if [%COMPILER%]==[MinGW-w64] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/x86_64-4.9.1-release-posix-seh-rt_v3-rev1.7z" -FileName mw64.7z
91-
- if [%COMPILER%]==[MinGW-w64] 7z x -oC:\ mw64.7z > NUL
92-
- if [%COMPILER%]==[MinGW-w64] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/5cff7d1736877336cf9fb58267111beea4fa152f/gmp-6.0.0-x86_64-w64-mingw32.7z" -FileName gmp.7z
93-
- if [%COMPILER%]==[MinGW-w64] 7z x -oC:\mingw64 gmp.7z > NUL
94-
95-
- if NOT [%COMPILER%]==[MSVC15] call symengine-cpp\bin\appveyor-download.cmd "https://raw.githubusercontent.com/symengine/dependencies/dcc10cce2133e2b57e61c5ced6120139bbcdfa20/python-libs-mingw32.7z" -FileName pylibs.7z
96-
- if NOT [%COMPILER%]==[MSVC15] 7z x -aoa -oC:\ pylibs.7z > NUL
55+
- call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
56+
- set "CONDA_DEPS=mpir=3.0.0 vc=14"
57+
- if [%WITH_MPFR%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpfr=3.1.5"
58+
- if [%WITH_MPC%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% mpc=1.0.3"
59+
- if [%WITH_LLVM%]==[yes] set "CONDA_DEPS=%CONDA_DEPS% llvmdev=4.0"
60+
- set "CONDA_DEPS=%CONDA_DEPS% -c conda-forge"
61+
- if [%BUILD_TYPE%]==[Debug] set "CONDA_DEPS=%CONDA_DEPS% -c symengine/label/debug"
62+
- conda create -n deps --yes %CONDA_DEPS%
63+
- call conda activate deps
64+
- echo %CONDA_PREFIX%
65+
- echo %PATH%
66+
- set "PATH=%PATH%;%CONDA_PREFIX%\\Library\\bin;%CONDA_PREFIX%"
67+
- echo %PATH%
9768

9869
- set "PATH=C:\Python%PYTHON_VERSION%;C:\Python%PYTHON_VERSION%\Scripts;%PATH%"
9970
- echo %PATH%
100-
- pip install nose pytest cython setuptools
71+
- pip install pytest cython scikit-build-core cython-cmake setuptools_scm
10172
- if NOT [%WITH_NUMPY%]==[no] pip install numpy
10273
- if NOT [%WITH_SYMPY%]==[no] pip install sympy
10374

@@ -107,14 +78,10 @@ install:
10778
- mkdir build
10879
- cd build
10980

110-
- if [%COMPILER%]==[MSVC15] set "CMAKE_GENERATOR=Visual Studio 16 2019"
111-
- if [%COMPILER%]==[MSVC15] set "CMAKE_GENERATOR_PLATFORM=%PLATFORM%"
112-
- if [%COMPILER%]==[MinGW] set "CMAKE_GENERATOR=MinGW Makefiles"
113-
- if [%COMPILER%]==[MinGW-w64] set "CMAKE_GENERATOR=MinGW Makefiles"
81+
- set "CMAKE_GENERATOR=Visual Studio 16 2019"
82+
- set "CMAKE_GENERATOR_PLATFORM=%PLATFORM%"
11483

115-
- if [%COMPILER%]==[MSVC15] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\\Library"
116-
- if [%COMPILER%]==[MinGW] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:\MinGW -DCMAKE_BUILD_TYPE=%BUILD_TYPE%"
117-
- if [%COMPILER%]==[MinGW-w64] set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=C:\mingw64 -DCMAKE_BUILD_TYPE=%BUILD_TYPE%"
84+
- set "CMAKE_ARGS=-DCMAKE_PREFIX_PATH=%CONDA_PREFIX%\\Library"
11885

11986
- if [%WITH_MPFR%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_MPFR=yes"
12087
- if [%WITH_MPC%]==[yes] set "CMAKE_ARGS=%CMAKE_ARGS% -DWITH_MPC=yes"
@@ -130,12 +97,10 @@ build_script:
13097
- set "PATH=C:\symengine\bin\;%PATH%"
13198
- set "SYMENGINE_PY_ADD_PATH_TO_SEARCH_DIRS=1"
13299
- echo %PATH%
133-
- if [%COMPILER%]==[MSVC15] python setup.py install build_ext --compiler=msvc --build-type=%BUILD_TYPE%
134-
- if [%COMPILER%]==[MinGW] python setup.py install build_ext --compiler=mingw --inplace
135-
- if [%COMPILER%]==[MinGW-w64] python setup.py install build_ext --compiler=mingw --inplace
100+
- set "CMAKE_ARGS="
101+
- python -m pip install -e . --no-build-isolation -Ccmake.build-type=%BUILD_TYPE% -vv
136102

137103
test_script:
138-
- if not [%COMPILER%]==[MSVC15] nosetests
139104
- mkdir empty && cd empty
140105
- python %PYTHON_SOURCE_DIR%\bin\test_python.py
141106

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.

0 commit comments

Comments
 (0)