Skip to content

Commit 9106752

Browse files
authored
Merge pull request #195 from agseaton/add_pyproject_toml
Add pyproject.toml file
2 parents 534699a + cb37eb7 commit 9106752

7 files changed

+80
-106
lines changed

CMakeLists.txt

+17-8
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,25 @@ endif()
151151
if(heyoka_WITH_REAL AND ${Python3_NumPy_VERSION} LESS 1.22)
152152
message(FATAL_ERROR "The minimum version of NumPy required for supporting arbitrary-precision computations is 1.22, but version ${Python3_NumPy_VERSION} was found instead")
153153
endif()
154-
# Extract the major.minor version of NumPy for use in the wheel configuration.
155-
string(REGEX MATCH "([0-9]+)\.([0-9]+)" _HEYOKA_PY_NPY_MAJOR_MINOR ${Python3_NumPy_VERSION})
156-
message(STATUS "NumPy major.minor version: ${_HEYOKA_PY_NPY_MAJOR_MINOR}")
154+
# NOTE: NumPy 2 not supported yet if we are building with support
155+
# for mppp::real or mppp::real128.
156+
if((heyoka_WITH_REAL OR heyoka_WITH_REAL128) AND ${Python3_NumPy_VERSION} VERSION_GREATER_EQUAL 2)
157+
message(FATAL_ERROR "NumPy 2 is not supported when building with support for quadruple-precision or arbitrary-precision computations")
158+
endif()
159+
message(STATUS "NumPy version: ${Python3_NumPy_VERSION}")
160+
unset(_HEYOKA_PY_PYTHON3_COMPONENTS)
161+
162+
if (DEFINED SKBUILD)
163+
# If we're using scikit-build-core, set install path to the current
164+
# directory since skbuild will be handling the installation.
165+
set(HEYOKA_PY_INSTALL_PATH "." CACHE STRING "heyoka module installation path")
157166

158-
set(HEYOKA_PY_INSTALL_PATH "" CACHE STRING "heyoka module installation path")
167+
# Also ensure shared libraries can be found in RPATH.
168+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
169+
else()
170+
set(HEYOKA_PY_INSTALL_PATH "" CACHE STRING "heyoka module installation path")
171+
endif()
159172
mark_as_advanced(HEYOKA_PY_INSTALL_PATH)
160-
unset(_HEYOKA_PY_PYTHON3_COMPONENTS)
161173

162174
# pybind11.
163175
find_package(pybind11 REQUIRED CONFIG)
@@ -194,6 +206,3 @@ endif()
194206

195207
# Add the module directory.
196208
add_subdirectory(heyoka)
197-
198-
# Cleanup.
199-
unset(_HEYOKA_PY_NPY_MAJOR_MINOR)

doc/changelog.rst

+9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ Changelog
66
6.1.0 (unreleased)
77
------------------
88

9+
New
10+
~~~
11+
12+
- Add a proper ``pyproject.toml`` file and use it to produce
13+
the binary wheels
14+
(`#195 <https://github.com/bluescarni/heyoka.py/pull/195>`__).
15+
916
Fix
1017
~~~
1118

19+
- Do not open the heyoka.py compiled module with ``RTLD_GLOBAL``
20+
(`#197 <https://github.com/bluescarni/heyoka.py/pull/197>`__).
1221
- Workaround for a clang 17 issue that would result in
1322
runtime exceptions during (de)serialisation
1423
(`#196 <https://github.com/bluescarni/heyoka.py/pull/196>`__).

heyoka/CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# Configure the version file.
22
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/_version.py.in" "${CMAKE_CURRENT_BINARY_DIR}/_version.py" @ONLY)
33

4-
# Configure the files needed to make the python wheels (for PyPI packages).
5-
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
6-
message(STATUS "Creating the files for the generation of a binary wheel.")
7-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../tools/wheel_setup.py" "${CMAKE_CURRENT_BINARY_DIR}/../wheel/setup.py" @ONLY)
8-
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../tools/wheel_setup.cfg" "${CMAKE_CURRENT_BINARY_DIR}/../wheel/setup.cfg" @ONLY)
9-
endif()
10-
114
# The list of heyoka.py's Python files.
125
set(HEYOKA_PY_PYTHON_FILES
136
__init__.py

pyproject.toml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[build-system]
2+
build-backend = 'scikit_build_core.build'
3+
requires = ['scikit-build-core', 'numpy >= 1.22, < 2']
4+
5+
[project]
6+
name = 'heyoka'
7+
version = '6.1.0'
8+
description = "Python library for ODE integration via Taylor's method and LLVM"
9+
readme = 'README.md'
10+
requires-python = '>=3.5'
11+
dependencies = ['cloudpickle', 'numpy >= 1.22, < 2']
12+
authors = [
13+
{ name = 'Francesco Biscarni', email = '[email protected]' },
14+
{ name = 'Dario Izzo' },
15+
]
16+
license = { text = 'MPL-2.0' }
17+
classifiers = [
18+
# How mature is this project? Common values are
19+
# 3 - Alpha
20+
# 4 - Beta
21+
# 5 - Production/Stable
22+
"Development Status :: 5 - Production/Stable",
23+
"Operating System :: OS Independent",
24+
"Intended Audience :: Science/Research",
25+
"Topic :: Scientific/Engineering",
26+
"Topic :: Scientific/Engineering :: Mathematics",
27+
"Topic :: Scientific/Engineering :: Physics",
28+
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
29+
"Programming Language :: Python :: 3",
30+
]
31+
keywords = ['science', 'math', 'physics', 'ode']
32+
33+
[project.urls]
34+
Documentation = "https://bluescarni.github.io/heyoka.py/index.html"
35+
Repository = "https://github.com/bluescarni/heyoka.py"
36+
37+
[project.optional-dependencies]
38+
sympy = ["sympy", "mpmath"]
39+
sgp4 = ["skyfield"]
40+
41+
[tool.scikit-build]
42+
# Avoid copying the C++ source files when building
43+
# binary wheels.
44+
wheel.packages = []
45+
# Enable IPO.
46+
cmake.define.HEYOKA_PY_ENABLE_IPO = "ON"

tools/gha_manylinux.sh

+8-34
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ git config --global --add safe.directory ${GITHUB_WORKSPACE}
1515
BRANCH_NAME=`git rev-parse --abbrev-ref HEAD`
1616
echo "BRANCH_NAME: ${BRANCH_NAME}"
1717

18-
# Read for what python wheels have to be built.
18+
# Detect the Python version.
1919
if [[ ${HEYOKA_PY_BUILD_TYPE} == *38* ]]; then
2020
PYTHON_DIR="cp38-cp38"
2121
elif [[ ${HEYOKA_PY_BUILD_TYPE} == *39* ]]; then
@@ -33,16 +33,9 @@ else
3333
exit 1
3434
fi
3535

36-
# Report the inferred directory whwere python is found.
36+
# Report the inferred directory where python is found.
3737
echo "PYTHON_DIR: ${PYTHON_DIR}"
3838

39-
# The numpy version heyoka.py will be built against.
40-
if [[ ${HEYOKA_PY_BUILD_TYPE} == *312* || ${HEYOKA_PY_BUILD_TYPE} == *313* ]]; then
41-
export NUMPY_VERSION="1.26.*"
42-
else
43-
export NUMPY_VERSION="1.24.*"
44-
fi
45-
4639
# The heyoka version to be used for releases.
4740
export HEYOKA_VERSION_RELEASE="6.1.0"
4841

@@ -54,15 +47,7 @@ else
5447
echo "Non-tag build detected"
5548
fi
5649

57-
# Python mandatory deps.
58-
# NOTE: explicit installation of setuptools is apparently
59-
# needed in Python 3.13.
60-
/opt/python/${PYTHON_DIR}/bin/pip install numpy==${NUMPY_VERSION} cloudpickle setuptools
61-
# Python optional deps.
62-
/opt/python/${PYTHON_DIR}/bin/pip install sympy mpmath skyfield
63-
64-
# In the pagmo2/manylinux2014_x86_64_with_deps:latest image in dockerhub
65-
# the working directory is /root/install, we will install heyoka there.
50+
# In the manylinux image in dockerhub the working directory is /root/install, we will install heyoka there.
6651
cd /root/install
6752

6853
# Install heyoka.
@@ -85,30 +70,19 @@ cmake -DHEYOKA_WITH_MPPP=yes \
8570
-DCMAKE_BUILD_TYPE=Release ../;
8671
make -j4 install
8772

88-
# Install heyoka.py.
73+
# Build the heyoka.py wheel.
8974
cd ${GITHUB_WORKSPACE}
90-
mkdir build
91-
cd build
92-
cmake -DCMAKE_BUILD_TYPE=Release \
93-
-DHEYOKA_PY_ENABLE_IPO=ON \
94-
-DPython3_EXECUTABLE=/opt/python/${PYTHON_DIR}/bin/python ../;
95-
make -j4 install
96-
97-
# Making the wheel and installing it
98-
cd wheel
99-
# Move the installed heyoka.py files into the current dir.
100-
mv `/opt/python/${PYTHON_DIR}/bin/python -c 'import site; print(site.getsitepackages()[0])'`/heyoka ./
101-
# Create the wheel and repair it.
75+
/opt/python/${PYTHON_DIR}/bin/pip wheel . -v
76+
# Repair it.
10277
# NOTE: this is temporary because some libraries in the docker
10378
# image are installed in lib64 rather than lib and they are
10479
# not picked up properly by the linker.
10580
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib"
106-
/opt/python/${PYTHON_DIR}/bin/python setup.py bdist_wheel
107-
auditwheel repair dist/heyoka* -w ./dist2
81+
auditwheel repair ./heyoka*.whl -w ./repaired_wheel
10882
# Try to install it and run the tests.
10983
unset LD_LIBRARY_PATH
11084
cd /
111-
/opt/python/${PYTHON_DIR}/bin/pip install ${GITHUB_WORKSPACE}/build/wheel/dist2/heyoka*
85+
/opt/python/${PYTHON_DIR}/bin/pip install ${GITHUB_WORKSPACE}/repaired_wheel/heyoka*
11286
cd ${GITHUB_WORKSPACE}/tools
11387
/opt/python/${PYTHON_DIR}/bin/python ci_test_runner.py
11488
cd /

tools/wheel_setup.cfg

-2
This file was deleted.

tools/wheel_setup.py

-55
This file was deleted.

0 commit comments

Comments
 (0)