forked from robotology/gym-ignition-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
131 lines (106 loc) · 4.38 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.
import os
import shutil
import platform
from setuptools.command.build_ext import build_ext
from setuptools import setup, find_packages, Extension
class CopyMeshes(Extension):
extension_name = "CopyMeshes"
def __init__(self):
Extension.__init__(self, name=self.extension_name, sources=[])
class BuildExtension(build_ext):
"""
Setuptools build extension handler.
It processes all the extensions listed in the 'ext_modules' entry.
"""
# Name of the python package (the name used to import the module)
PACKAGE_NAME = "gym_ignition_models"
# Shared mesh directory
SHARED_MESH_DIR = "meshes"
# Dict that defines the folders to copy during the build process
FROM_ORIG_TO_DEST = {
f"{SHARED_MESH_DIR}/iCubGazeboV2_5": "iCubGazeboV2_5/meshes",
f"{SHARED_MESH_DIR}/iCubGazeboV2_5": "iCubGazeboSimpleCollisionsV2_5/meshes",
}
def run(self) -> None:
if len(self.extensions) != 1 or not isinstance(self.extensions[0], CopyMeshes):
raise RuntimeError("This class can only build one CopyMeshes object")
if platform.system() != "Linux":
raise RuntimeError("Only Linux is currently supported")
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext) -> None:
if ext.name != CopyMeshes.extension_name:
print(f"Skipping unsupported extension '{ext.name}'")
return
if self.inplace:
raise RuntimeError("Editable mode is not supported by this project")
# Get the temporary external build directory
ext_dir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# Package directory
pkg_dir = os.path.join(ext_dir, self.PACKAGE_NAME)
# Check that the directory exists
if not os.path.isdir(pkg_dir):
raise RuntimeError(f"The build package directory '{pkg_dir}' does not exist")
# Copy the folders
for orig, dest in self.FROM_ORIG_TO_DEST.items():
orig_folder = os.path.join(pkg_dir, orig)
dest_folder = os.path.join(pkg_dir, dest)
if not os.path.isdir(orig_folder):
raise RuntimeError(f"Folder '{orig_folder}' does not exist")
if os.path.isdir(dest_folder):
shutil.rmtree(dest_folder)
shutil.copytree(orig_folder, dest_folder)
# Remove the shared mesh folder
shutil.rmtree(os.path.join(pkg_dir, self.SHARED_MESH_DIR))
# Read the contents of your README file
this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup(
name="gym-ignition-models",
author="Diego Ferigo",
author_email="[email protected]",
description="Additional robot models for RL simulations",
long_description=long_description,
long_description_content_type='text/markdown',
license="LGPL",
platforms='any',
classifiers=[
"Development Status :: 4 - Beta",
"Operating System :: POSIX :: Linux",
"Topic :: Games/Entertainment :: Simulation",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Framework :: Robot Framework",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
],
use_scm_version={
'local_scheme': 'dirty-tag',
},
setup_requires=['setuptools_scm'],
python_requires='>=3.6',
keywords="robot model robotics humanoid simulation urdf sdf icub",
packages=find_packages(),
package_data={'gym_ignition_models': [
'meshes/*.*',
'meshes/**/*.*',
'meshes/**/**/*.*',
'*/meshes/*.*',
'*/meshes/**/*.*',
'*/meshes/**/**/*.*',
'*/*.sdf',
'*/*.urdf',
'*/model.config',
]},
ext_modules=[CopyMeshes()],
cmdclass={
'build_ext': BuildExtension,
},
url="https://github.com/dic-iit/gym-ignition-models",
)