Skip to content

Commit 38a309c

Browse files
committed
update tests
1 parent c8cf765 commit 38a309c

File tree

4 files changed

+48
-52
lines changed

4 files changed

+48
-52
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ jobs:
88
fail-fast: false
99
matrix:
1010
include:
11+
- BUILD_TYPE: Release
12+
PYTHON_VERSION: '3.13'
13+
BUILD_SHARED_LIBS: yes
14+
SYMENGINE_PY_LIMITED_API: '3.11'
15+
OS: ubuntu-22.04
16+
CC: gcc
17+
1118
- BUILD_TYPE: Debug
1219
WITH_BFD: yes
1320
PYTHON_VERSION: '3.12'
@@ -197,6 +204,7 @@ jobs:
197204
MAKEFLAGS: ${{ matrix.MAKEFLAGS }}
198205
BUILD_SHARED_LIBS: ${{ matrix.BUILD_SHARED_LIBS }}
199206
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
207+
SYMENGINE_PY_LIMITED_API: ${{ matrix.SYMENGINE_PY_LIMITED_API }}
200208

201209
- name: Deploy Documentation
202210
if: ${{ (github.ref == 'refs/heads/main' && github.repository == 'Symengine/symengine.py') || (github.ref == 'refs/heads/master' && github.repository == 'Symengine/symengine.py')}}

bin/install_travis.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ if [[ "${WITH_FLINT_PY}" == "yes" ]]; then
2020
export conda_pkgs="${conda_pkgs} python-flint"; # python-flint affects sympy, see e.g. sympy/sympy#26645
2121
fi
2222

23+
if [[ "${SYMENGINE_PY_LIMITED_API}" != "" ]]; then
24+
export conda_pkgs="${conda_pkgs} abi3audit"
25+
fi
26+
2327
if [[ "${WITH_SAGE}" == "yes" ]]; then
2428
# This is split to avoid the 10 minute limit
2529
conda install -q sagelib=8.1
@@ -33,4 +37,4 @@ if [[ "${WITH_SYMPY}" != "no" ]]; then
3337
pip install sympy;
3438
fi
3539

36-
conda clean --all
40+
conda clean --all

bin/test_travis.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ cd symengine-*
1414
# Build inplace so that nosetests can be run inside source directory
1515
python3 setup.py install build_ext --inplace --symengine-dir=$our_install_dir
1616

17+
if [[ "${SYMENGINE_PY_LIMITED_API:-}" != "" ]]; then
18+
python3 -m abi3audit --assume-minimum-abi3 {SYMENGINE_PY_LIMITED_API} symengine/lib/symengine_wrapper.abi3.so
19+
fi
20+
1721
# Test python wrappers
1822
python3 -m pip install pytest
1923
python3 -m pytest -s -v $PWD/symengine/tests/test_*.py

setup.py

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,29 @@
33
import subprocess
44
import sys
55
import platform
6+
from setuptools import setup
7+
from setuptools.command.install import install as _install
8+
from setuptools.command.build_ext import build_ext as _build_ext
9+
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
10+
from setuptools.command.build import build as _build
611

712
# Make sure the system has the right Python version.
813
if sys.version_info[:2] < (3, 9):
914
print("SymEngine requires Python 3.9 or newer. "
1015
"Python %d.%d detected" % sys.version_info[:2])
1116
sys.exit(-1)
1217

13-
# use setuptools by default as per the official advice at:
14-
# packaging.python.org/en/latest/current.html#packaging-tool-recommendations
15-
use_setuptools = True
16-
# set the environment variable USE_DISTUTILS=True to force the use of distutils
17-
use_distutils = getenv('USE_DISTUTILS')
18-
if use_distutils is not None:
19-
if use_distutils.lower() == 'true':
20-
use_setuptools = False
18+
def _get_limited_api():
19+
value = os.environ.get("SYMENGINE_PY_LIMITED_API")
20+
if not value:
21+
return None
2122
else:
22-
print("Value {} for USE_DISTUTILS treated as False".
23-
format(use_distutils))
24-
25-
if use_setuptools:
26-
try:
27-
from setuptools import setup
28-
from setuptools.command.install import install as _install
29-
from setuptools.command.build_ext import build_ext as _build_ext
30-
except ImportError:
31-
use_setuptools = False
32-
else:
33-
try:
34-
from setuptools.command.build import build as _build
35-
except ImportError:
36-
from distutils.command.build import build as _build
23+
version = tuple(map(int, value.split(".")))
24+
if version < (3, 11):
25+
raise ValueError(f"symengine needs at least python 3.11 limited API support. Got {value}")
26+
return version
3727

38-
if not use_setuptools:
39-
from distutils.core import setup
40-
from distutils.command.install import install as _install
41-
from distutils.command.build_ext import build_ext as _build_ext
42-
from distutils.command.build import build as _build
28+
limited_api = _get_limited_api()
4329

4430
cmake_opts = [("PYTHON_BIN", sys.executable),
4531
("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")]
@@ -92,7 +78,6 @@ def initialize_options(self):
9278
self.symengine_dir = None
9379
self.generator = None
9480
self.build_type = "Release"
95-
self.py_limited_api = None
9681

9782
def finalize_options(self):
9883
_build_ext.finalize_options(self)
@@ -125,12 +110,8 @@ def cmake_build(self):
125110
if not path.exists(path.join(build_dir, "CMakeCache.txt")):
126111
cmake_cmd.extend(self.get_generator())
127112

128-
if self.py_limited_api:
129-
assert self.py_limited_api.startswith("cp3")
130-
py_ver_minor = int(self.py_limited_api[3:])
131-
if py_ver_minor < 11:
132-
raise ValueError(f"symengine needs at least cp311 limited API support. Got {self.py_limited_api}")
133-
h = 3 * 16**6 + py_ver_minor * 16**4
113+
if limited_api:
114+
h = limited_api[0] * 16**6 + limited_api[1] * 16**4
134115
cmake_cmd.append(f"-DWITH_PY_LIMITED_API={h}")
135116

136117
if subprocess.call(cmake_cmd, cwd=build_dir) != 0:
@@ -206,21 +187,20 @@ def run(self):
206187
_install.run(self)
207188
self.cmake_install()
208189

190+
class BdistWheelWithCmake(_bdist_wheel):
191+
def finalize_options(self):
192+
_bdist_wheel.finalize_options(self)
193+
self.root_is_pure = False
194+
if limited_api:
195+
self.py_limited_api = f"cp{"".join(str(c) for c in limited_api)}"
196+
209197
cmdclass={
210-
'build': BuildWithCmake,
211-
'build_ext': BuildExtWithCmake,
212-
'install': InstallWithCmake,
213-
}
214-
215-
try:
216-
from wheel.bdist_wheel import bdist_wheel
217-
class BdistWheelWithCmake(bdist_wheel):
218-
def finalize_options(self):
219-
bdist_wheel.finalize_options(self)
220-
self.root_is_pure = False
221-
cmdclass["bdist_wheel"] = BdistWheelWithCmake
222-
except ImportError:
223-
pass
198+
'build': BuildWithCmake,
199+
'build_ext': BuildExtWithCmake,
200+
'install': InstallWithCmake,
201+
'bdist_wheel': BdistWheelWithCmake,
202+
}
203+
224204

225205
long_description = '''
226206
SymEngine is a standalone fast C++ symbolic manipulation library.
@@ -235,13 +215,13 @@ def finalize_options(self):
235215
setup(name="symengine",
236216
version="0.14.1",
237217
description="Python library providing wrappers to SymEngine",
238-
setup_requires=['cython>=0.29.24', 'setuptools'],
218+
setup_requires=['cython>=0.29.24', 'setuptools>=70.1.0'],
239219
long_description=long_description,
240220
author="SymEngine development team",
241221
author_email="[email protected]",
242222
license="MIT",
243223
url="https://github.com/symengine/symengine.py",
244-
python_requires='>=3.9,<4',
224+
python_requires=">=3.9,<4",
245225
zip_safe=False,
246226
packages=[],
247227
cmdclass = cmdclass,

0 commit comments

Comments
 (0)