-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
63 lines (50 loc) · 2.22 KB
/
setup.py
File metadata and controls
63 lines (50 loc) · 2.22 KB
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
import shutil
import urllib.request
import json
import os
# Configurations
delete_source_file = True
# SELECT YOUR PLATFORM
# 0 - linux_amd64
# 1 - linux_i386
# 4 - win32_mingw-w64
# 6 - win64_mingw-w64
platform = 6
# End of configurations
# Gets the necessary links in the raylib repo
latest_release_url = "https://api.github.com/repos/raysan5/raylib/releases/latest"
latest_release_json = json.load(urllib.request.urlopen(latest_release_url))
asset_download_link = latest_release_json["assets"][platform]["browser_download_url"]
asset_file_name = asset_download_link.replace(
"https://github.com/raysan5/raylib/releases/download/" + latest_release_json["tag_name"] + "/", "")
# Checks if already downloaded the file
if not os.path.exists(asset_file_name):
# Downloads the file
urllib.request.urlretrieve(asset_download_link, asset_file_name)
print(asset_file_name + " downloaded!")
else:
print(asset_file_name + " already downloaded!")
# Unpack the file
shutil.unpack_archive(asset_file_name)
print(asset_file_name + " extracted!")
if platform == 2 or platform == 3: # Set extension for Linux
folder_name = asset_file_name.replace(".tar.gz", "")
elif platform == 6 or platform == 8: # Set extension for Windows
folder_name = asset_file_name.replace(".zip", "")
if os.path.exists("./include"):
shutil.rmtree("./include")
if os.path.exists("./lib"):
shutil.rmtree("./lib")
# Moving the extracted files to the project folder
shutil.move("./" + folder_name + "/include", "./include")
shutil.move("./" + folder_name + "/lib", "./")
shutil.rmtree("./" + folder_name, ignore_errors=True)
print("raylib files moved with success!")
urllib.request.urlretrieve("https://raw.githubusercontent.com/raysan5/raylib/master/src/rlgl.h", "./include/rlgl.h")
urllib.request.urlretrieve("https://raw.githubusercontent.com/raysan5/raygui/master/src/raygui.h", "./include/raygui.h")
urllib.request.urlretrieve("https://raw.githubusercontent.com/raysan5/raylib/master/src/raymath.h", "./include"
"/raymath.h")
# Deletes the precompiled binaries from github
if delete_source_file:
os.remove("./" + asset_file_name)
print("Finished!!!")