-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
86 lines (71 loc) · 2.57 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Setup script for the robot_properties_fingers package."""
import pathlib
from os import path
from setuptools import find_packages, setup
from setuptools.command.build_py import build_py
import xacro
package_name = "robot_properties_fingers"
class CustomBuildCommand(build_py):
"""Custom build command to process xacro files."""
def run(self) -> None:
"""Run the build command."""
# Call the original build_py command
build_py.run(self)
# Define the paths
xacro_dir = pathlib.Path("xacro_files")
urdf_dir = pathlib.Path(self.build_lib) / package_name / "urdf"
# Process each xacro file
for xacro_file in xacro_dir.glob("**/*.xacro"):
relative_urdf_path = xacro_file.relative_to(xacro_dir).with_suffix("")
urdf_file = urdf_dir / relative_urdf_path
# ensure output directory exists
urdf_file.parent.mkdir(parents=True, exist_ok=True)
# Use xacro API to process the file
doc = xacro.process_file(str(xacro_file))
urdf_content = doc.toprettyxml(indent=" ")
urdf_file.write_text(urdf_content)
def load_readme() -> str:
"""Load the README file."""
this_directory = pathlib.Path(__file__).parent
return (this_directory / "README.md").read_text()
setup(
name=package_name,
version="2.0.2",
packages=find_packages(where="src"),
package_dir={"": "src"},
package_data={"robot_properties_fingers": ["meshes/*.stl", "meshes/**/*.stl"]},
data_files=[
(
"share/ament_index/resource_index/packages",
[path.join("resource", package_name)],
),
(
path.join("share", package_name),
["package.xml"],
),
],
install_requires=[
"xacro",
"pin", # pinocchio
],
extras_require={"test": ["pytest"]},
zip_safe=True,
maintainer="Felix Kloss",
maintainer_email="[email protected]",
description="URDF files and meshes of the (Tri-)Finger robots.",
long_description=load_readme(),
long_description_content_type="text/markdown",
url="https://open-dynamic-robot-initiative.github.io/robot_properties_fingers/",
license="BSD-3-Clause",
tests_require=["pytest"],
entry_points={
"console_scripts": [],
},
cmdclass={"build_py": CustomBuildCommand},
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
],
)