forked from trackmania-rl/tmrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
154 lines (133 loc) · 5.53 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import os
import platform
import sys
from setuptools import find_packages, setup
from pathlib import Path
from shutil import copy2
from zipfile import ZipFile
import urllib.request
import urllib.error
import socket
if sys.version_info < (3, 7):
sys.exit('Sorry, Python < 3.7 is not supported. We use dataclasses that have been introduced in 3.7.')
RESOURCES_SRC = "./resources.zip"
def url_retrieve(url: str, outfile: Path, overwrite: bool = False):
"""
Adapted from https://www.scivision.dev/python-switch-urlretrieve-requests-timeout/
"""
outfile = Path(outfile).expanduser().resolve()
if outfile.is_dir():
raise ValueError("Please specify full filepath, including filename")
if overwrite or not outfile.is_file():
outfile.parent.mkdir(parents=True, exist_ok=True)
try:
urllib.request.urlretrieve(url, str(outfile))
except (socket.gaierror, urllib.error.URLError) as err:
raise ConnectionError(f"could not download {url} due to {err}")
# destination folder:
HOME_FOLDER = Path.home()
TMRL_FOLDER = HOME_FOLDER / "TmrlData"
# download relevant items IF THE tmrl FOLDER DOESN'T EXIST:
if not TMRL_FOLDER.exists():
# print("we create a new tmrldata folder")
CHECKPOINTS_FOLDER = TMRL_FOLDER / "checkpoints"
DATASET_FOLDER = TMRL_FOLDER / "dataset"
REWARD_FOLDER = TMRL_FOLDER / "reward"
WEIGHTS_FOLDER = TMRL_FOLDER / "weights"
CONFIG_FOLDER = TMRL_FOLDER / "config"
CHECKPOINTS_FOLDER.mkdir(parents=True, exist_ok=True)
DATASET_FOLDER.mkdir(parents=True, exist_ok=True)
REWARD_FOLDER.mkdir(parents=True, exist_ok=True)
WEIGHTS_FOLDER.mkdir(parents=True, exist_ok=True)
CONFIG_FOLDER.mkdir(parents=True, exist_ok=True)
# download resources:
RESOURCES_TARGET = TMRL_FOLDER / "resources.zip"
copy2(RESOURCES_SRC, RESOURCES_TARGET)
# unzip downloaded resources:
with ZipFile(RESOURCES_TARGET, 'r') as zip_ref:
zip_ref.extractall(TMRL_FOLDER)
# delete zip file:
RESOURCES_TARGET.unlink()
# copy relevant files:
RESOURCES_FOLDER = TMRL_FOLDER / "resources"
copy2(RESOURCES_FOLDER / "config.json", CONFIG_FOLDER)
copy2(RESOURCES_FOLDER / "reward.pkl", REWARD_FOLDER)
copy2(RESOURCES_FOLDER / "SAC_4_LIDAR_pretrained.tmod", WEIGHTS_FOLDER)
copy2(RESOURCES_FOLDER / "SAC_4_imgs_pretrained.tmod", WEIGHTS_FOLDER)
copy2(RESOURCES_FOLDER / "SAC_trackmap_pretrained.tmod", WEIGHTS_FOLDER)
# copy2(RESOURCES_FOLDER / "SAC_trackmap_pretrained_t.tcpt", CHECKPOINTS_FOLDER)
# on Windows, look for OpenPlanet:
if platform.system() == "Windows":
OPENPLANET_FOLDER = HOME_FOLDER / "OpenplanetNext"
if OPENPLANET_FOLDER.exists():
# copy the OpenPlanet script:
try:
OP_SCRIPTS_FOLDER = OPENPLANET_FOLDER / 'Plugins' / 'GrabData'
OP_SCRIPTS_FOLDER.mkdir(parents=True, exist_ok=True)
TM20_SCRIPT_FILE = RESOURCES_FOLDER / 'Plugins' / 'GrabData' / 'Plugin_GrabData_extended.as'
TM20_SCRIPT_FILE_INFO = RESOURCES_FOLDER / 'Plugins' / 'GrabData' / 'info.toml'
copy2(TM20_SCRIPT_FILE, OP_SCRIPTS_FOLDER)
copy2(TM20_SCRIPT_FILE_INFO, OP_SCRIPTS_FOLDER)
except Exception as e:
print(
f"An exception was caught when trying to copy the OpenPlanet script and signature automatically. \
Please copy these files manually for TrackMania 2020 support. The caught exception was: {str(e)}.")
else:
# warn the user that OpenPlanet couldn't be found:
print(f"The OpenPlanet folder was not found at {OPENPLANET_FOLDER}. \
Please copy the OpenPlanet script and signature manually for TrackMania 2020 support.")
install_req = [
'numpy',
'torch',
'imageio',
'imageio-ffmpeg',
'pandas',
'gym>=0.26.0',
'rtgym>=0.7',
'pyyaml',
'wandb',
'requests',
'opencv-python',
'scikit-image',
'keyboard',
'pyautogui',
'pyinstrument',
'tlspyo>=0.2.5',
'matplotlib'
]
if platform.system() == "Windows":
install_req.append('pywin32>=303')
install_req.append('vgamepad')
# The directory containing this file
HERE = os.path.abspath(os.path.dirname(__file__))
# The text of the README file
with open(os.path.join(HERE, "README.md")) as fid:
README = fid.read()
setup(
name='tmrl',
version='0.4.1',
description='Network-based framework for real-time robot learning',
long_description=README,
long_description_content_type='text/markdown',
keywords='reinforcement learning, robot learning, trackmania, self driving, roborace',
url='https://github.com/trackmania-rl/tmrl',
download_url='https://github.com/trackmania-rl/tmrl/archive/refs/tags/v0.4.1.tar.gz',
author='Yann Bouteiller, Edouard Geze',
author_email='[email protected], [email protected]',
license='MIT',
install_requires=install_req,
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Information Technology',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Topic :: Games/Entertainment',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
],
include_package_data=True,
extras_require={},
scripts=[],
packages=find_packages(exclude=("tests", )))