-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathdownload_msys2_prebuilt.py
69 lines (56 loc) · 1.91 KB
/
download_msys2_prebuilt.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
import logging
import subprocess
def install_pacman_package(pkg_name):
""" This installs a package in the current MSYS2 environment
Does not download again if the package is already installed
and if the version is the latest available in MSYS2
"""
output = subprocess.run(['pacman', '-S', '--noconfirm', pkg_name],
capture_output=True, text=True)
if output.returncode != 0:
logging.error(
"Error {} while downloading package {}: \n{}".
format(output.returncode, pkg_name, output.stderr))
return output.returncode != 0
def get_packages(x86=True, x64=True):
deps = [
'mingw-w64-{}-SDL2',
'mingw-w64-{}-SDL2_ttf',
'mingw-w64-{}-SDL2_image',
'mingw-w64-{}-SDL2_mixer',
'mingw-w64-{}-portmidi',
'mingw-w64-{}-libpng',
'mingw-w64-{}-libjpeg-turbo',
'mingw-w64-{}-libtiff',
'mingw-w64-{}-zlib',
'mingw-w64-{}-libwebp',
'mingw-w64-{}-libvorbis',
'mingw-w64-{}-libogg',
'mingw-w64-{}-flac',
'mingw-w64-{}-libmodplug',
'mingw-w64-{}-mpg123',
'mingw-w64-{}-opus',
'mingw-w64-{}-opusfile',
'mingw-w64-{}-freetype'
]
packages = []
if x86:
packages.extend([x.format('i686') for x in deps])
if x64:
packages.extend([x.format('x86_64') for x in deps])
return packages
def install_prebuilts(x86=True, x64=True):
""" For installing prebuilt dependencies.
"""
errors = False
print("Installing pre-built dependencies")
for pkg in get_packages(x86=x86, x64=x64):
print(f"Installing {pkg}")
error = install_pacman_package(pkg)
errors = errors or error
if errors:
raise Exception("Some dependencies could not be installed")
def update(x86=True, x64=True):
install_prebuilts(x86=x86, x64=x64)
if __name__ == '__main__':
update()