forked from lupoglaz/GodotAIGym
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
53 lines (45 loc) · 1.9 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
import os
import sys
import argparse
from shutil import copyfile, copytree, rmtree
from urllib import request
from zipfile import ZipFile
from pathlib import Path
GODOT_PATH = os.environ["GODOT_PATH"]
def download_unpack(rewrite=False):
# url = 'https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.7.0.zip'
url = 'https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.7.0%2Bcpu.zip'
if (not Path('libtorch.zip').exists()) or rewrite:
print('Downloading libtorch')
filedata = request.urlopen(url)
datatowrite = filedata.read()
with open('libtorch.zip', 'wb') as f:
f.write(datatowrite)
if (not Path('GodotModule/libtorch').exists()) or rewrite:
print('Extracting libtorch')
with ZipFile('libtorch.zip', 'r') as zipObj:
zipObj.extractall(path='GodotModule')
def compile_godot(godot_root, platform='x11', tools='yes', target='release_debug', bits=64):
current_path = os.getcwd()
os.chdir(godot_root)
os.system(f"scons platform={platform} tools={tools} target={target} bits={bits}")
os.chdir(current_path)
def install_module(godot_root, rewrite=False):
module_dir = os.path.join(godot_root, 'modules/GodotSharedMemory')
if (not os.path.exists(module_dir)):
copytree('GodotModule', module_dir)
elif rewrite:
rmtree(module_dir)
copytree('GodotModule', module_dir)
def install_python_module():
current_path = os.getcwd()
os.chdir('PythonModule')
os.system('python setup.py install')
os.chdir(current_path)
if __name__=='__main__':
download_unpack(rewrite=False)
install_module(godot_root=GODOT_PATH, rewrite=True)
install_python_module()
compile_godot(godot_root=GODOT_PATH, platform='x11', tools='yes', target='release_debug', bits=64)
compile_godot(godot_root=GODOT_PATH, platform='x11', tools='no', target='release_debug', bits=64)
compile_godot(godot_root=GODOT_PATH, platform='server', tools='no', target='release_debug', bits=64)