generated from Team-Audio/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_libfluidsynth.py
52 lines (40 loc) · 1.38 KB
/
get_libfluidsynth.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
import requests
import zipfile
import io
import argh
from os.path import join as opjoin
def download_fluidsynth(venv_path = 'venv'):
url = r'https://github.com/FluidSynth/fluidsynth/releases/download/v2.2.0/fluidsynth-2.2.0-win10-x64.zip'
zfolder = 'bin/'
export_folder = f'./{venv_path}/Scripts'
filelist = [
"libfluidsynth-3.dll",
"libgcc_s_seh-1.dll",
"libglib-2.0-0.dll",
"libgobject-2.0-0.dll",
"libgomp-1.dll",
"libgthread-2.0-0.dll",
"libinstpatch-2.dll",
"libintl-8.dll",
"libsndfile-1.dll",
"libstdc++-6.dll",
"libwinpthread-1.dll",
]
def naming_rule(x: str) -> str:
if x == "libfluidsynth-3.dll":
return "libfluidsynth.dll"
return x
print("Downloading Fluidsynth")
r = requests.get(url=url)
print("Extracting fluidsynth")
try:
with zipfile.ZipFile(io.BytesIO(r.content)) as z:
for file in filelist:
path = opjoin(zfolder,file)
with z.open(path,'r') as zfile:
with open(opjoin(export_folder,naming_rule(file)),'wb') as out:
out.write(zfile.read())
except Exception as e:
print("Error extracting",e)
if __name__ == '__main__':
argh.dispatch_command(download_fluidsynth)