forked from openai/roboschool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
123 lines (107 loc) · 3.84 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
from setuptools import setup, find_packages
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import subprocess
import sys, os
import re
dep = """
C++ dependencies for this project are:
bullet
tinyxml
boost_python
assimp
Qt5
If you see compilation error FIRST THING TO CHECK if pkg-config call was successful.
Install dependencies that pkg-config cannot find.
"""
from setuptools.command.install import install as DistutilsInstall
from setuptools.command.egg_info import egg_info as EggInfo
setup_py_dir = os.path.dirname(os.path.realpath(__file__))
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
from sys import platform
if platform=="darwin":
bulletlibs = "libBullet2FileLoader libBulletCollision libBullet3Collision libBulletDynamics libBullet3Common libBulletInverseDynamics".split()
bulletlibs += "libBullet3Dynamics libBulletSoftBody libBullet3Geometry libLinearMath libBullet3OpenCL_clew libPhysicsClientC_API".split()
for x in bulletlibs:
os.system("install_name_tool -id @loader_path/cpp-household/bullet_local_install/lib/%s.2.87.dylib %s/%s.2.87.dylib" % (x,blib,x))
for y in bulletlibs:
os.system("install_name_tool -change @rpath/%s.2.87.dylib @loader_path/%s.2.87.dylib %s/%s.2.87.dylib" % (x,x,blib,y))
def recompile():
global platform
USE_PYTHON3 = ""
if sys.version_info[0]==2:
USE_PYTHON3 = "USE_PYTHON3=0"
print("recompile for platform %s\n" % platform)
if platform=="win32":
sep = " && "
magic = "echo %PATH% && "
cmdprefix = "cmd /C \"%s" % magic
cmdsuffix = "\""
fileExt = "dll"
make_prefix = "mingw32-"
fileSuffix = "-cpython-36m"
else:
sep = " && "
cmdprefix = ""
cmdsuffix = ""
fileExt = "so"
make_prefix = ""
fileSuffix = ""
cmd = sep.join((
"cd %s/roboschool/cpp-household" % setup_py_dir,
"%smake clean" % make_prefix,
"%smake -j4 dirs %s ../cpp_household%s.%s" %(make_prefix, USE_PYTHON3,fileSuffix,fileExt)
))
cmd = "%s%s%s" % (cmdprefix,cmd,cmdsuffix)
print(cmd)
res = os.system(cmd)
if res:
print(dep)
sys.exit(1)
class MyInstall(DistutilsInstall):
def run(self):
recompile()
DistutilsInstall.run(self)
class MyEgg(EggInfo):
def run(self):
recompile()
EggInfo.run(self)
class Build(build_ext):
def run(self):
pass
if platform=="win32":
fileExt = "dll"
fileSuffix = "-cpython-36m"
else:
fileExt = "so"
fileSuffix = ""
need_files = ['cpp_household%s.%s' % (fileSuffix,fileExt)]
hh = setup_py_dir + "/roboschool"
need_files_ext = 'png jpg urdf obj mtl dae off stl STL xml glsl dylib'.split()
need_files_re = [re.compile(r'.+\.'+p) for p in need_files_ext]
need_files_re.append(re.compile(r'.+\.so(.\d+)*'))
need_files_re.append(re.compile(r'.+/\.libs/.+'))
need_files_re.append(re.compile(r'.+/\.qt_plugins/.+'))
for root, dirs, files in os.walk(hh):
for fn in files:
fn = root + '/' + fn
if any([p.match(fn) for p in need_files_re]):
need_files.append(fn[1+len(hh):])
print("found resource files: %i" % len(need_files))
for n in need_files: print("-- %s" % n)
setup(
name = 'roboschool',
version = '1.0.38',
description = 'OpenAI Household Simulator: mobile manipulation using Bullet',
maintainer = 'Oleg Klimov',
maintainer_email = '[email protected]',
url = 'https://github.com/openai/roboschool',
packages=[x for x in find_packages()],
ext_modules=[CMakeExtension('roboschool')],
cmdclass={'build_ext': Build},
install_requires=['gym'],
package_data = { '': need_files }
)