-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_renpy_steam.py
124 lines (90 loc) · 3.07 KB
/
update_renpy_steam.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
#!/usr/bin/env python3
import traceback
import urllib.request
import os
import zipfile
def download(fn):
"""
Downloads a file and installs it into Ren'Py.
"""
dn = os.path.dirname(fn)
if not os.path.exists(dn):
print("For {}, the directory doesn't exist, not doing anything.".format(fn))
return
basename = os.path.basename(fn)
url = "https://raw.githubusercontent.com/renpy/steam-deck-guide/master/files/" + basename
print("Downloading", url, "to", fn + ".")
with urllib.request.urlopen(url) as response:
data = response.read().decode("utf-8")
with open(fn, "w", encoding="utf-8") as f:
f.write(data)
# The path to steamworks_sdk.zip
steamworks_zip = ""
def find_steamworks_zip():
global steamworks_zip
steamworks_zips = [
i for i in os.listdir(".")
if i.lower().startswith("steamworks_sdk") and i.lower().endswith(".zip") ]
steamworks_zips.sort()
if steamworks_zips:
steamworks_zip = steamworks_zips[-1]
print("Found steamworks at", steamworks_zip + ".")
else:
print("Could not find steamworks.")
raise SystemExit()
def steamworks(src, dst):
"""
Unpacks a steamworks file from `src` to `dst` if required.
"""
# Add a prefix to src, to save typing.
src = "sdk/redistributable_bin/" + src
dst = dst + "/" + os.path.basename(src)
dn = os.path.dirname(dst)
if not os.path.exists(dn):
print("For {}, the directory doesn't exist, not doing anything.".format(dst))
return
with zipfile.ZipFile(steamworks_zip) as zf:
with zf.open(src) as f:
data = f.read()
with open(dst, "wb") as f:
f.write(data)
print("Unpacked {}.".format(dst))
def main():
# Change to the directory containing this file.
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if not os.path.exists("renpy/common"):
print("This file is not inside a Ren'Py SDK or Game.")
return
else:
print("Ren'Py found.")
# Find steamworks.
find_steamworks_zip()
# Download the Ren'Py files.
print()
print("Downloading Ren'Py files:")
print()
download("renpy/common/00achievement.rpy")
download("renpy/common/00steam.rpy")
download("lib/python2.7/steamapi.py")
download("lib/pythonlib2.7/steamapi.py")
print()
print("Unpacking steamworks:")
print()
steamworks("linux32/libsteam_api.so", "lib/linux-i686")
steamworks("linux64/libsteam_api.so", "lib/linux-x86_64")
steamworks("osx/libsteam_api.dylib", "lib/darwin-x86_64")
steamworks("osx/libsteam_api.dylib", "lib/mac-x86_64")
steamworks("steam_api.dll", "lib/windows-i686")
steamworks("win64/steam_api64.dll", "lib/windows-x86_64")
print()
print("The Steam API was updated. You can delete this file and {}.".format(steamworks_zip))
print("I'm making a note here, huge success.")
print()
if __name__ == "__main__":
try:
main()
except:
traceback.print_exc()
print("")
print("")
input("Press enter to end this program.")