Skip to content

Commit 0d5c356

Browse files
committed
Updated interface for numpy > 2.0
1 parent 730aa8a commit 0d5c356

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ venv.bak/
111111
cpp/.clangd
112112
build*
113113
cpp/doc/CMakeFiles/*
114-
cpp/doc/doc/*
114+
cpp/doc/doc/*
115+
*.c

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "Cython", "oldest-supported-numpy"]
2+
requires = ["setuptools", "wheel", "Cython", "numpy"]
33
build-backend = "setuptools.build_meta"
44

setup.py

+28-20
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414

1515
URL = "https://github.com/hungpham2511/toppra"
1616

17-
1817
# setup requirements
1918
if sys.version[0] == '2':
2019
with open("requirements.txt", "r") as f:
21-
REQUIRES = ["scipy==0.18.0", "numpy", "matplotlib",
22-
# only required on python2.7
23-
"pathlib2", "enum34", "strip_hints", "typing"]
20+
REQUIRES = [
21+
"scipy==0.18.0",
22+
"numpy",
23+
"matplotlib",
24+
# only required on python2.7
25+
"pathlib2",
26+
"enum34",
27+
"strip_hints",
28+
"typing"
29+
]
2430
DEV_REQUIRES = [line.strip() for line in f if line.strip()]
2531
else:
2632
with open("requirements3.txt", "r") as f:
@@ -33,16 +39,13 @@
3339
LICENSE = "MIT"
3440

3541
SRC_DIR = "toppra"
36-
PACKAGES = ["toppra",
37-
"toppra.constraint",
38-
"toppra.algorithm",
39-
"toppra.algorithm.reachabilitybased",
40-
"toppra.solverwrapper",
41-
"toppra.cpp"]
42-
43-
ext_1 = Extension(SRC_DIR + "._CythonUtils",
44-
[SRC_DIR + "/_CythonUtils.pyx"],
45-
extra_compile_args=['-O1'],
42+
PACKAGES = [
43+
"toppra", "toppra.constraint", "toppra.algorithm",
44+
"toppra.algorithm.reachabilitybased", "toppra.solverwrapper", "toppra.cpp"
45+
]
46+
47+
ext_1 = Extension(SRC_DIR + "._CythonUtils", [SRC_DIR + "/_CythonUtils.pyx"],
48+
extra_compile_args=['-O2'],
4649
libraries=[],
4750
include_dirs=[np.get_include()])
4851

@@ -60,17 +63,20 @@
6063
# custom install command: strip type-hints before installing toppra
6164
# for python2.7 and pthon3.5
6265
class install2(install):
66+
6367
def run(self, *args, **kwargs):
6468
# stripping
6569
if sys.version[0] == '2' or sys.version[:3] == '3.5':
6670
from strip_hints import strip_file_to_string
6771
import glob
6872
import os.path
73+
6974
def process_file(f):
7075
print(os.path.abspath(f))
7176
out = strip_file_to_string(f)
7277
with open(f, 'w') as fh:
7378
fh.write(out)
79+
7480
for f in glob.glob("%s/*/toppra/*/*.py" % self.build_base):
7581
process_file(f)
7682
for f in glob.glob("%s/*/toppra/*.py" % self.build_base):
@@ -89,11 +95,11 @@ def process_file(f):
8995
setup_requires=["numpy", "cython"],
9096
extras_require={
9197
# Dependencies installed when running `pip install -e .[dev]`
92-
98+
9399
# NOTE: This is deprecated in favour of the simpler workflow
94100
# of installing from requirements3.txt before installing
95101
# this pkg.
96-
'dev': DEV_REQUIRES
102+
'dev': DEV_REQUIRES
97103
},
98104
packages=PACKAGES,
99105
zip_safe=False,
@@ -107,12 +113,14 @@ def process_file(f):
107113
url=URL,
108114
license=LICENSE,
109115

110-
# This is used to build the Cython modules. Will be run
116+
# This is used to build the Cython modules. Will be run
111117
# automatically if not found by pip. Otherwise run
112118
#
113119
# python setup.py build
114120
#
115121
# to trigger manually.
116-
cmdclass={"build_ext": build_ext, "install": install2},
117-
ext_modules=cythonize(EXTENSIONS)
118-
)
122+
cmdclass={
123+
"build_ext": build_ext,
124+
"install": install2
125+
},
126+
ext_modules=cythonize(EXTENSIONS))

toppra/solverwrapper/cy_seidel_solverwrapper.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ from libc.math cimport abs, pow, isnan
55
cimport cython
66
from cpython.array cimport array, clone
77

8-
ctypedef np.int_t INT_t
9-
ctypedef np.float_t FLOAT_t
8+
ctypedef np.int64_t INT_t
9+
ctypedef np.float64_t FLOAT_t
1010

1111
from ..constraint import ConstraintType
1212

0 commit comments

Comments
 (0)