-
Notifications
You must be signed in to change notification settings - Fork 11
/
setup_deps.py
745 lines (620 loc) · 25.9 KB
/
setup_deps.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
#! /usr/bin/env python
# Copyright (c) 2020, Fabio Muratore, Honda Research Institute Europe GmbH, and
# Technical University of Darmstadt.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the Fabio Muratore, Honda Research Institute Europe GmbH,
# or Technical University of Darmstadt. nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL FABIO MURATORE, HONDA RESEARCH INSTITUTE EUROPE GMBH,
# OR TECHNICAL UNIVERSITY DAMRSTADT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
import argparse
import errno
import os
import os.path as osp
import shutil
import subprocess as sp
import sys
import tarfile
import tempfile
import zipfile
from urllib.request import urlretrieve
# Get the project's root directory
project_dir = osp.dirname(osp.abspath(__file__))
# Check if we are in CI
CI = "CI" in os.environ
# Make sure the git submodules are up to date, otherwise this script might break them
if not CI:
sp.check_call(["git", "submodule", "update", "--init"], cwd=project_dir)
# Check if we are in HRI by looking for the SIT envionment variable
IN_HRI = "SIT" in os.environ
# ================== #
# PARSE ARGS EAGERLY #
# ================== #
# Allows to use them in the configuration
parser = argparse.ArgumentParser(description="Setup RcsPySim dev env")
parser.add_argument(
"tasks",
metavar="task",
type=str,
nargs="*",
help="Subtasks to execute. Suggested tasks are `all` (includes every feature) or `no_rcs` (excludes Rcs and RcsPysim). To get a list of all availibe tasks, run `python setup_deps.py`.",
)
parser.add_argument(
"--vortex", dest="vortex", action="store_true", default=False, help="Use vortex physics engine (default: False)"
)
parser.add_argument("--no_vortex", dest="vortex", action="store_false", help="Do not use vortex physics engine")
parser.set_defaults(vortex=False)
parser.add_argument("--cuda", dest="usecuda", action="store_true", help="Use CUDA for PyTorch (default: False)")
parser.add_argument("--no_cuda", dest="usecuda", action="store_false", help="Do not use CUDA for PyTorch")
parser.set_defaults(usecuda=False)
parser.add_argument("--headless", action="store_true", default=False, help="Build in headless mode")
parser.add_argument(
"--local_torch",
dest="uselibtorch",
action="store_true",
help="Use the local libtorch from the thirdParty directory for RcsPySim (default: True)",
)
parser.add_argument(
"--no_local_torch",
dest="uselibtorch",
action="store_false",
help="Do not use the local libtorch from the thirdParty directory for RcsPySim",
)
parser.set_defaults(uselibtorch=True)
parser.add_argument(
"--pip_check",
action="store_true",
default=False,
help="Run ´pip check´ after installing the dependencies (default: False)",
)
parser.add_argument("-j", default=1, type=int, help="Number of make threads")
args = parser.parse_args()
# Check for help print later, when the tasks are defined
# ====== #
# CONFIG #
# ====== #
# Common directories
dependency_dir = osp.join(project_dir, "thirdParty")
resources_dir = osp.join(dependency_dir, "resources")
# Global cmake prefix path
cmake_prefix_path = []
conda_prefix = os.getenv("CONDA_PREFIX")
if conda_prefix:
# Anaconda env root directory
cmake_prefix_path.append(conda_prefix)
# Required packages
required_packages = [
# "g++-4.8", # necessary for Vortex
"qt5-default", # conda install -c dsdale24 qt5 _OR_ conda install -c anaconda qt __OR__ HEADLESS BUILD
# conda install -c dsdale24 qt5 _OR_ conda install -c anaconda qt __OR__ HEADLESS BUILD
"libqwt-qt5-dev",
"libbullet-dev", # conda install -c conda-forge bullet
"libfreetype6-dev", # conda install -c anaconda freetype
"libxml2-dev", # conda install -c anaconda libxml2
"libglu1-mesa-dev", # conda install -c anaconda libglu
"freeglut3-dev", # conda install -c anaconda freeglut
"mesa-common-dev", # conda install -c conda-forge mesalib
# conda install -c conda-forge openscenegraph __OR__ HEADLESS BUILD
"libopenscenegraph-dev",
"openscenegraph", # conda install -c conda-forge openscenegraph __OR__ HEADLESS BUILD
"liblapack-dev", # conda install -c conda-forge lapack
"doxygen", # necessary for building the Rcs documentation
"python3-distutils", # necessary for installing PyTorch
]
# using --headless: conda install -c conda-forge bullet freetype libglu freeglut mesalib lapack
env_vars = {
# Global cmake prefix path
"CMAKE_PREFIX_PATH": ":".join(cmake_prefix_path)
}
# Number of threads for make
make_parallelity = args.j
# WM5
# wm5_download_url = 'https://www.geometrictools.com/Downloads/WildMagic5p17.zip' # deprecated
wm5_download_url = "https://github.com/zhouxs1023/WildMagic/archive/master.zip"
wm5_src_dir = osp.join(dependency_dir, "WildMagic5")
wm5_config = "ReleaseDynamic"
wm5_modules = ["LibCore", "LibMathematics"]
wm5_include_dir = osp.join(wm5_src_dir, "SDK/Include")
wm5_library_dir = osp.join(wm5_src_dir, "SDK/Library", wm5_config)
# Rcs
rcs_src_dir = osp.join(project_dir, "Rcs")
rcs_build_dir = osp.join(rcs_src_dir, "build")
rcs_cmake_vars = {
"USE_BULLET": "2.83_float",
"ENABLE_C++11": "ON",
# Eigen is off for now until the dependency issues are fixed in Rcs.
# Must specify include dir for Eigen 3.2
# "EIGEN3_INCLUDE_DIR": eigen_include_dir,
# "USE_EIGEN": "ON",
"USE_WM5": "ON", # for advanced collision models
"WRITE_PACKAGE_REGISTRY": "ON",
}
# Optional headless mode
if args.headless:
rcs_cmake_vars["HEADLESS_BUILD"] = "ON"
# Bullet
if IN_HRI:
# Use bullet double from SIT
# double causes errors due to soft bodies
rcs_cmake_vars["USE_BULLET"] = "2.83_float"
else:
# Bullet from apt-get package is in float mode
rcs_cmake_vars["USE_BULLET"] = "2.83_float"
# Vortex
if args.vortex:
rcs_cmake_vars["USE_VORTEX"] = "ESSENTIALS"
else:
rcs_cmake_vars["USE_VORTEX"] = "OFF"
# WM5 collision library
if not IN_HRI:
rcs_cmake_vars["WM5_INCLUDE_DIR"] = wm5_include_dir
rcs_cmake_vars["WM5_LIBRARY_DIR"] = wm5_library_dir
# Kuka iiwa meshes
iiwa_repo_version = "1.2.5"
iiwa_url = f"https://github.com/IFL-CAMP/iiwa_stack/archive/{iiwa_repo_version}.tar.gz"
# Schunk SDH meshes
sdh_repo_version = "0.6.14"
sdh_url = f"https://github.com/ipa320/schunk_modular_robotics/archive/{sdh_repo_version}.tar.gz"
# Barrett WAM meshes (Pyrado)
wam_repo_version = "354c6e9"
wam_url = f"https://github.com/psclklnk/self-paced-rl/archive/{wam_repo_version}.tar.gz"
# PyTorch
# NOTE: Assumes that the current environment does NOT already contain PyTorch!
pytorch_version = "1.8.1"
pytorch_git_repo = "https://github.com/pytorch/pytorch.git"
pytorch_src_dir = osp.join(dependency_dir, "pytorch")
# RcsPySim
rcspysim_src_dir = osp.join(project_dir, "RcsPySim")
rcspysim_build_dir = osp.join(rcspysim_src_dir, "build")
uselibtorch = "ON" if args.uselibtorch else "OFF"
rcspysim_cmake_vars = {
"PYBIND11_PYTHON_VERSION": "3.7",
"SETUP_PYTHON_DEVEL": "ON",
"Rcs_DIR": rcs_build_dir,
# Do NOT set CMAKE_PREFIX_PATH here, it will get overridden later on.
}
# Pyrado
pyrado_dir = osp.join(project_dir, "Pyrado")
# Robcom & SL
cppsctp_git_repo = "https://git.ias.informatik.tu-darmstadt.de/robcom/cppsctp.git"
sl_git_repo = "https://git.ias.informatik.tu-darmstadt.de/sl/sl.git"
robcom_git_repo = "https://git.ias.informatik.tu-darmstadt.de/robcom-2/robcom-2.0.git"
ias_dir = osp.join(dependency_dir, "ias")
cppsctp_dir = osp.join(dependency_dir, "ias", "cppsctp")
sl_dir = osp.join(dependency_dir, "ias", "sl")
robcom_dir = osp.join(dependency_dir, "ias", "robcom")
cppsctp_cmake_vars = {"IAS_DIR": ias_dir}
cppsctpinstall_dir = osp.join(cppsctp_dir, "install")
sl_cmake_vars = {"IAS_DIR": ias_dir, "BUILD_barrett": "ON"}
# ======= #
# HELPERS #
# ======= #
def mkdir_p(path):
"""Create directory and parents if it doesn't exist."""
try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
def downloadAndExtract(url, destdir, archiveContentPath=None):
"""Download an archive and extract it to the given destination."""
# Select archive format
if url.endswith(".tar.gz"):
suffix = ".tar.gz"
path_attr = "path"
elif url.endswith(".zip"):
suffix = ".zip"
path_attr = "filename"
else:
raise ValueError("Unsupported archive file: {}".format(url))
if osp.exists(destdir) and len(os.listdir(destdir)) != 0:
# Exists, skip
return
with tempfile.NamedTemporaryFile(suffix=suffix) as tf:
print("Downloading {}...".format(url))
urlretrieve(url, tf.name)
print("Extracting {}...".format(url))
# Ensure destdir exists
mkdir_p(destdir)
# Filter
if archiveContentPath is not None:
# We only want to extract one subdirectory
# Taken from https://stackoverflow.com/a/43094365
def members(ml):
subfolder = osp.normpath(archiveContentPath)
for member in ml:
# Skip directories in zip
isdir = getattr(member, "is_dir", None)
if isdir and isdir():
continue
# Modify output path
path = getattr(member, path_attr)
rp = osp.relpath(path, subfolder)
if not rp.startswith(".."):
setattr(member, path_attr, rp)
yield member
else:
def members(ml):
return ml
if suffix == ".tar.gz":
with tarfile.open(tf.name) as tar:
def is_within_directory(directory, target):
abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)
prefix = os.path.commonprefix([abs_directory, abs_target])
return prefix == abs_directory
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")
tar.extractall(path, members, numeric_owner=numeric_owner)
safe_extract(tar, members=members(tar.getmembers()), path=destdir)
else:
with zipfile.ZipFile(tf.name) as zip:
zip.extractall(members=members(zip.infolist()), path=destdir)
def buildCMakeProject(srcDir, buildDir, cmakeVars=None, env=env_vars, install_dir=None):
"""
cd buildDir
cmake srcDir -D...
make
(make install)
"""
# Ensure build dir exists
mkdir_p(buildDir)
if env is not None:
fullenv = dict(os.environ)
fullenv.update(env)
env = fullenv
# Execute CMake command
cmake_cmd = ["cmake", osp.relpath(srcDir, buildDir)]
if cmakeVars is not None:
for k, v in cmakeVars.items():
if v is True:
vstr = "ON"
elif v is False:
vstr = "OFF"
else:
vstr = v
cmake_cmd.append("-D{}={}".format(k, vstr))
if install_dir is not None:
cmake_cmd.append("-DCMAKE_INSTALL_PREFIX={}".format(install_dir))
sp.check_call(cmake_cmd, cwd=buildDir, env=env)
# Execute make (build) command
make_cmd = ["make", "-j{}".format(make_parallelity)]
sp.check_call(make_cmd, cwd=buildDir, env=env)
# Execute install command if desired
if install_dir is not None:
mkdir_p(install_dir)
sp.check_call(["make", "install"], cwd=buildDir)
# =========== #
# SETUP TASKS #
# =========== #
def setup_dep_libraries():
# Update
quiet = [] if not CI else ["-qq"]
sp.check_call(["sudo", "apt-get"] + quiet + ["update", "-y"])
# Install dependencies
sp.check_call(["sudo", "apt-get"] + quiet + ["install", "-y"] + required_packages)
def setup_wm5():
# Download the sources
downloadAndExtract(wm5_download_url, wm5_src_dir, "WildMagic-master")
# Build relevant modules
for module in wm5_modules:
sp.check_call(
[
"make",
"-f",
"makefile.wm5",
"build",
"CFG={}".format(wm5_config),
"-j{}".format(make_parallelity),
"--quiet",
],
cwd=osp.join(wm5_src_dir, module),
)
def setup_rcs():
# We need to apply a patch to the ControllerBase.cpp file of Rcs
controller_file = osp.join(rcs_src_dir, "src", "RcsCore", "ControllerBase.cpp")
# Open the file
file = open(controller_file, "r")
# Apply patch to line 910
replaced_content = ""
for line in file:
if line.strip() == "if ((a_des==NULL) || (MatNd_get2(a_des, i, 0)>0.0))":
new_line = line.replace(")>0", ")!=0")
else:
new_line = line
replaced_content = replaced_content + new_line
file.close()
# Write the patched file
write_file = open(controller_file, "w")
write_file.write(replaced_content)
write_file.close()
# Build Rcs. We already have it in the submodule
buildCMakeProject(rcs_src_dir, rcs_build_dir, cmakeVars=rcs_cmake_vars)
def setup_pytorch():
# Get PyTorch from git
if not osp.exists(pytorch_src_dir):
mkdir_p(pytorch_src_dir)
sp.check_call(
[
"git",
"clone",
"--recursive",
"--branch",
"v{}".format(pytorch_version),
pytorch_git_repo,
pytorch_src_dir,
]
)
# Let it's setup do the magic
env = os.environ.copy()
env.update(env_vars)
# CUDA is disabled by default
env["USE_CUDA"] = "ON" if args.usecuda else "OFF"
# CUDA is disabled by default
env["USE_CUDNN"] = "ON" if args.usecuda else "OFF"
# disable MKLDNN; mkl/blas deprecated error https://github.com/pytorch/pytorch/issues/17874
env["USE_MKLDNN"] = "OFF"
env["_GLIBCXX_USE_CXX11_ABI"] = "1"
sp.check_call([sys.executable, "setup.py", "install"], cwd=pytorch_src_dir, env=env)
def setup_rcspysim():
# Take care of RcsPySim
buildCMakeProject(rcspysim_src_dir, rcspysim_build_dir, cmakeVars=rcspysim_cmake_vars)
def setup_iiwa():
# The Kuka iiwa meshes
downloadAndExtract(
iiwa_url, osp.join(resources_dir, "iiwa_description"), f"iiwa_stack-{iiwa_repo_version}/iiwa_description"
)
# Copy the relevant mesh files into RcsPySim's config folder
# We already have the .tri meshes in there, just gives them company.
src_dir = osp.join(resources_dir, "iiwa_description/meshes/iiwa14")
dst_dir = osp.join(rcspysim_src_dir, "config/iiwa_description/meshes/iiwa14")
# Collision and visual for links 0 - 7
print("Copying the KUKA iiwa meshes to the RcsPySim config dir ...")
for catdir in ["collision", "visual"]:
for lnum in range(8):
fname = osp.join(catdir, f"link_{lnum}.stl")
mkdir_p(osp.dirname(osp.join(dst_dir, fname)))
shutil.copyfile(osp.join(src_dir, fname), osp.join(dst_dir, fname))
print("Setting up the KUKA iiwa meshes is done.")
def setup_schunk():
# The Schunk SDH meshes
downloadAndExtract(
sdh_url,
osp.join(resources_dir, "schunk_description"),
f"schunk_modular_robotics-{sdh_repo_version}/schunk_description",
)
# Copy the relevant mesh files into RcsPySim's config folder
# We already have the .tri meshes in there, just gives them company.
src_dir = osp.join(resources_dir, "schunk_description/meshes/sdh")
dst_dir = osp.join(rcspysim_src_dir, "config/schunk_description/meshes/sdh")
# Get all .stl files in the sdh subdir
print("Copying the Schunk SDH meshes to the RcsPySim config dir ...")
for fname in os.listdir(src_dir):
if fname.endswith(".stl"):
mkdir_p(osp.dirname(osp.join(dst_dir, fname)))
shutil.copyfile(osp.join(src_dir, fname), osp.join(dst_dir, fname))
print("Setting up the Schunk SDH meshes is done.")
def setup_wam():
# Barrett WAM meshes (Pyrado)
downloadAndExtract(
wam_url, osp.join(resources_dir, "wam_description"), f"self-paced-rl-{wam_repo_version}/sprl/envs/xml/"
)
# Copy the relevant mesh files into Pyrados's MuJoCo environments folder
src_dir = osp.join(resources_dir, "wam_description/meshes")
dst_dir = osp.join(pyrado_dir, "pyrado/environments/mujoco/assets/meshes/barrett_wam")
# Get all .stl files in the wam subdir
print("Copying the Barrett WAM meshes to the Pyrado assets dir ...")
for fname in os.listdir(src_dir):
if fname.endswith(".stl"):
mkdir_p(osp.dirname(osp.join(dst_dir, fname)))
shutil.copyfile(osp.join(src_dir, fname), osp.join(dst_dir, fname))
print("Setting up the Barrett WAM meshes is done.")
def setup_meshes():
# Set up all external meshes
setup_iiwa()
setup_schunk()
setup_wam()
def setup_pre_commit():
# Set up pre-commit used for the Black code formatter
sp.check_call([sys.executable, "-m", "pip", "install", "pre-commit"])
sp.check_call(["pre-commit", "install"], cwd=osp.join(project_dir, ".github"))
def setup_pyrado():
# Set up Pyrado in development mode
sp.check_call([sys.executable, "setup.py", "develop"], cwd=osp.join(project_dir, "Pyrado"))
def setup_render_pipeline():
# Set up RenderPipeline (custom fork)
sp.check_call([sys.executable, "setup.py"], cwd=osp.join(project_dir, "thirdParty", "RenderPipeline"))
def setup_pytorch_based():
# Locally build PyTorch>=1.7.0 requires dataclasses (does not harm when using pytorch from pip)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "dataclasses"])
# Set up GPyTorch without touching the PyTorch installation (requires scikit-learn which requires threadpoolctl)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "threadpoolctl"])
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "scikit-learn"])
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "gpytorch"])
# Set up BoTorch without touching the PyTorch installation (requires gpytorch)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "botorch"])
# Set up Pyro without touching the PyTorch installation (requires opt-einsum)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "opt-einsum"])
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "pyro-api"])
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "pyro-ppl"])
# Set up SBI without touching the PyTorch installation (requires Pyro and pyknos which requires nflows)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "nflows"])
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "pyknos"])
sp.check_call(
[sys.executable, "-m", "pip", "install", "-U", "--no-deps", "sbi==0.12.0"]
) # 0.18 is the last version before arviz
# Downgrade to avoid the incompatibility with cliff (whatever cliff is)
sp.check_call([sys.executable, "-m", "pip", "install", "-U", "--no-deps", "prettytable==0.7.2"])
if args.pip_check:
# Check the installations
print("Checking dependencies of the packages installed via pip:")
sp.check_call([sys.executable, "-m", "pip", "check"])
def setup_cppsctp():
# Install dependencies
required_packages_sctp = [
"libsctp-dev",
]
user_input = input(
f"You are about to install SL which depends on the following libraries:"
f"\n{required_packages_sctp}\nDo you really want this? [y / n] "
)
if user_input.lower() == "y":
sp.check_call(["sudo", "apt-get", "install", "-y"] + required_packages_sctp)
print("Dependencies have been installed.")
else:
print("Dependencies have NOT been installed.")
# Get it all GitLab
if not osp.exists(cppsctp_dir):
mkdir_p(cppsctp_dir)
sp.check_call(["git", "clone", cppsctp_git_repo, cppsctp_dir])
# Create relative build dir
cppsctp_build_dir = osp.join(cppsctp_dir, "build")
if not osp.exists(cppsctp_build_dir):
mkdir_p(cppsctp_dir)
# Build it
buildCMakeProject(cppsctp_dir, cppsctp_build_dir, cmakeVars=cppsctp_cmake_vars, install_dir=cppsctpinstall_dir)
def setup_sl():
# Install dependencies (copied from https://git.ias.informatik.tu-darmstadt.de/robcom-2/robcom-2.0/-/wikis/usage)
required_packages_sl = [
"libsctp-dev",
"libncurses5-dev",
"libreadline6-dev",
"freeglut3-dev",
"libxmu-dev",
"cmake-curses-gui",
"libedit-dev",
"clang",
"xterm",
]
user_input = input(
f"You are about to install SL which depends on the following libraries:"
f"\n{required_packages_sl}\nDo you really want this? [y / n] "
)
if user_input.lower() == "y":
sp.check_call(["sudo", "apt-get", "install", "-y"] + required_packages_sl)
print("Dependencies have been installed.")
else:
print("Dependencies have NOT been installed.")
# Set up custom IAS dependency
setup_cppsctp()
# Get it all GitLab
if not osp.exists(sl_dir):
mkdir_p(sl_dir)
sp.check_call(["git", "clone", sl_git_repo, sl_dir])
# Create relative build dir
sl_build_dir = osp.join(sl_dir, "build")
if not osp.exists(sl_build_dir):
mkdir_p(sl_build_dir)
# Build it
buildCMakeProject(sl_dir, sl_build_dir, cmakeVars=sl_cmake_vars)
def setup_robcom():
# Set up dependency
setup_cppsctp()
# Get it all GitLab
if not osp.exists(robcom_dir):
mkdir_p(robcom_dir)
sp.check_call(["git", "clone", robcom_git_repo, robcom_dir])
# Install it suing its setup script
env = os.environ.copy()
env.update(env_vars)
env["BUILD_ROBCIMPYTHON_WRAPPER"] = "ON"
env["IAS_DIR"] = ias_dir
env["INSTALL_IN_IAS_DIR"] = "ON"
sp.check_call([sys.executable, "setup.py", "install", "--user"], cwd=robcom_dir, env=env)
def setup_wo_rcs_wo_pytorch():
print("\nStarting Option Red Velvet Setup\n")
# Rcs will still be downloaded since it is a submodule
setup_wam() # ignoring the meshes used in RcsPySim
if not CI:
setup_pyrado()
if not args.headless:
setup_render_pipeline()
setup_pytorch_based()
print("\nWAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are set up!\n")
def setup_wo_rcs_w_pytorch():
print("\nStarting Option Malakoff Setup\n")
# Rcs will still be downloaded since it is a submodule
setup_pytorch()
setup_wam() # ignoring the meshes used in RcsPySim
if not CI:
setup_pyrado()
if not args.headless:
setup_render_pipeline()
setup_pytorch_based()
print("\nPyTorch, WAM meshes, Pyrado (with GPyTorch, BoTorch, and Pyro using the --no-deps flag) are " "set up!\n")
def setup_w_rcs_wo_pytorch():
print("\nStarting Option Sacher Setup\n")
# We could do setup_dep_libraries() here, but it requires sudo rights
if not IN_HRI:
setup_wm5()
setup_rcs()
# don't use the local PyTorch but the one from anaconda/pip
rcspysim_cmake_vars["USE_LIBTORCH"] = "OFF"
if not CI:
setup_rcspysim()
setup_meshes()
if not CI:
setup_pyrado()
if not args.headless:
setup_render_pipeline()
setup_pytorch_based()
print(
"\nWM5, Rcs, RcsPySim, iiwa & Schunk & WAM meshes and Pyrado (with GPyTorch, BoTorch, and Pyro "
"using the --no-deps flag) are set up!\n"
)
def setup_w_rcs_w_pytorch():
print("\nStarting Option Black Forest Setup\n")
# We could do setup_dep_libraries() here, but it requires sudo rights
if not IN_HRI:
setup_wm5()
setup_rcs()
setup_pytorch()
if not CI:
setup_rcspysim()
setup_meshes()
if not CI:
setup_pyrado()
if not args.headless:
setup_render_pipeline()
setup_pytorch_based()
print(
"\nWM5, Rcs, PyTorch, RcsPySim, iiwa & Schunk & WAM meshes, Pyrado (with GPyTorch, BoTorch, and "
"Pyro using the --no-deps flag) are set up!\n"
)
# All tasks list
tasks_by_name = {name[6:]: v for name, v in globals().items() if name.startswith("setup_")} # cut the "setup_"
# ==== #
# MAIN #
# ==== #
# Print help if none
if len(args.tasks) == 0:
print("Available tasks:")
for n in tasks_by_name.keys():
print(" {}".format(n))
# Execute selected tasks
for task in args.tasks:
tasks_by_name[task]()