Colcon Build error using Cython in setup.py [closed]
Hi,
I'm using ROS2 Eloquent on Ubuntu 18.04 and im trying to use from Cython.Build import cythonize
in my setup.py
.
My package contains the file cythontest.pyx
and the first time i launch colcon build
i get an error but the correspronding cythontest.c
is created in the same directory. When launching colcon build
again and the error is gone and i can launch my node with the method from cythontest.pyx
.
But if the cythontest.c
gets deleted the same pattern occurs again.
To clarify I tested this file outside of the ros2 envoriment and it works fine.
My setup.py
from setuptools import setup, find_packages
from Cython.Build import cythonize
package_name = 'object_detector'
setup(
ext_modules=cythonize("object_detector/cythontest.pyx"),
name=package_name,
version='0.0.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
],
install_requires=['setuptools', "wheel", "Cython"],
zip_safe=True,
maintainer='simon',
maintainer_email='...',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
'console_scripts': [
'object_detection = object_detector.object_detection:main'
],
},
)
The following error occurs
colcon build
Starting >>> detection_data
Starting >>> realsense2_camera_msgs
Starting >>> camera_calibration
Starting >>> realsense2_description
Finished <<< realsense2_description [0.95s]
Finished <<< camera_calibration [1.35s]
Finished <<< realsense2_camera_msgs [1.59s]
Starting >>> realsense2_camera
Finished <<< detection_data [1.65s]
Starting >>> object_detector
/home/simon/.local/lib/python3.6/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /home/simon/sciebo/Uni/7_Semester/Bachelor_Arbeit/IS_Bachelor_Arbeit/Bachelor_Thesis/Datentraeger_Dateien/Software/IS/dev_ws/src/object_detector/object_detector/cythontest.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
--- stderr: object_detector
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/colcon_core/executor/__init__.py", line 91, in __call__
rc = await self.task(*args, **kwargs)
File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 93, in __call__
return await task_method(*args, **kwargs)
File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build
setup_py_data = get_setup_data(self.context.pkg, env)
File "/usr/lib/python3/dist-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
return dict(pkg.metadata[key](env))
File "/usr/lib/python3/dist-packages/colcon_ros/package_identification/ros.py", line 130, in getter
desc.path / 'setup.py', env=env)
File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 242, in get_setup_information
setup_py, env=env)
File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 286, in _get_setup_information
return ast.literal_eval(output)
File "/usr/lib/python3.6/ast.py", line 48, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
Compiling object_detector/cythontest.pyx because it changed.
^
SyntaxError: invalid syntax
---
Failed <<< object_detector [0.87s, exited with code 1]
Aborted <<< realsense2_camera [0.91s]
Summary: 4 packages finished [2.80s]
1 package failed: object_detector
1 package aborted: realsense2_camera
1 package had stderr output: object_detector
invalid syntax (<unknown>, line 1)