Skip to content

Commit 9f55710

Browse files
committed
reduce diff
1 parent 38a309c commit 9f55710

File tree

2 files changed

+54
-21
lines changed

2 files changed

+54
-21
lines changed

bin/test_travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cd symengine-*
1515
python3 setup.py install build_ext --inplace --symengine-dir=$our_install_dir
1616

1717
if [[ "${SYMENGINE_PY_LIMITED_API:-}" != "" ]]; then
18-
python3 -m abi3audit --assume-minimum-abi3 {SYMENGINE_PY_LIMITED_API} symengine/lib/symengine_wrapper.abi3.so
18+
python3 -m abi3audit --assume-minimum-abi3 ${SYMENGINE_PY_LIMITED_API} symengine/lib/symengine_wrapper.abi3.so
1919
fi
2020

2121
# Test python wrappers

setup.py

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
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
116

127
# Make sure the system has the right Python version.
138
if sys.version_info[:2] < (3, 9):
@@ -27,6 +22,37 @@ def _get_limited_api():
2722

2823
limited_api = _get_limited_api()
2924

25+
# use setuptools by default as per the official advice at:
26+
# packaging.python.org/en/latest/current.html#packaging-tool-recommendations
27+
use_setuptools = True
28+
# set the environment variable USE_DISTUTILS=True to force the use of distutils
29+
use_distutils = getenv('USE_DISTUTILS')
30+
if use_distutils is not None:
31+
if use_distutils.lower() == 'true':
32+
use_setuptools = False
33+
else:
34+
print("Value {} for USE_DISTUTILS treated as False".
35+
format(use_distutils))
36+
37+
if use_setuptools:
38+
try:
39+
from setuptools import setup
40+
from setuptools.command.install import install as _install
41+
from setuptools.command.build_ext import build_ext as _build_ext
42+
except ImportError:
43+
use_setuptools = False
44+
else:
45+
try:
46+
from setuptools.command.build import build as _build
47+
except ImportError:
48+
from distutils.command.build import build as _build
49+
50+
if not use_setuptools:
51+
from distutils.core import setup
52+
from distutils.command.install import install as _install
53+
from distutils.command.build_ext import build_ext as _build_ext
54+
from distutils.command.build import build as _build
55+
3056
cmake_opts = [("PYTHON_BIN", sys.executable),
3157
("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")]
3258
cmake_generator = [None]
@@ -187,20 +213,27 @@ def run(self):
187213
_install.run(self)
188214
self.cmake_install()
189215

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-
197216
cmdclass={
198-
'build': BuildWithCmake,
199-
'build_ext': BuildExtWithCmake,
200-
'install': InstallWithCmake,
201-
'bdist_wheel': BdistWheelWithCmake,
202-
}
203-
217+
'build': BuildWithCmake,
218+
'build_ext': BuildExtWithCmake,
219+
'install': InstallWithCmake,
220+
}
221+
222+
try:
223+
try:
224+
from setuptools.command.bdist_wheel import bdist_wheel
225+
except ImportError:
226+
from wheel.bdist_wheel import bdist_wheel
227+
228+
class BdistWheelWithCmake(bdist_wheel):
229+
def finalize_options(self):
230+
bdist_wheel.finalize_options(self)
231+
self.root_is_pure = False
232+
if limited_api:
233+
self.py_limited_api = "cp" + "".join(str(c) for c in limited_api)
234+
cmdclass["bdist_wheel"] = BdistWheelWithCmake
235+
except ImportError:
236+
pass
204237

205238
long_description = '''
206239
SymEngine is a standalone fast C++ symbolic manipulation library.
@@ -215,13 +248,13 @@ def finalize_options(self):
215248
setup(name="symengine",
216249
version="0.14.1",
217250
description="Python library providing wrappers to SymEngine",
218-
setup_requires=['cython>=0.29.24', 'setuptools>=70.1.0'],
251+
setup_requires=['cython>=0.29.24', 'setuptools'],
219252
long_description=long_description,
220253
author="SymEngine development team",
221254
author_email="[email protected]",
222255
license="MIT",
223256
url="https://github.com/symengine/symengine.py",
224-
python_requires=">=3.9,<4",
257+
python_requires='>=3.9,<4',
225258
zip_safe=False,
226259
packages=[],
227260
cmdclass = cmdclass,

0 commit comments

Comments
 (0)