-
Notifications
You must be signed in to change notification settings - Fork 202
/
generate_licenses.py
309 lines (284 loc) · 9.68 KB
/
generate_licenses.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import json
import os
import subprocess
import urllib.request
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import List, Optional
@dataclass
class License:
name: str
version: Optional[str]
license: Optional[str]
text: str
def generate_licenses() -> List[License]:
licenses: List[License] = []
# openjtalk
# https://sourceforge.net/projects/open-jtalk/files/Open%20JTalk/open_jtalk-1.11/
licenses.append(
License(
name="Open JTalk",
version="1.11",
license="Modified BSD license",
text=Path("docs/licenses/open_jtalk/COPYING").read_text(),
)
)
licenses.append(
License(
name="MeCab",
version=None,
license="Modified BSD license",
text=Path("docs/licenses/open_jtalk/mecab/COPYING").read_text(),
)
)
licenses.append(
License(
name="NAIST Japanese Dictionary",
version=None,
license="Modified BSD license",
text=Path("docs/licenses//open_jtalk/mecab-naist-jdic/COPYING").read_text(),
)
)
with urllib.request.urlopen(
"https://raw.githubusercontent.com/r9y9/pyopenjtalk/master/pyopenjtalk/htsvoice/LICENSE_mei_normal.htsvoice" # noqa: B950
) as res:
licenses.append(
License(
name='HTS Voice "Mei"',
version=None,
license="Creative Commons Attribution 3.0 license",
text=res.read().decode(),
)
)
# VOICEVOX CORE
with urllib.request.urlopen(
"https://raw.githubusercontent.com/VOICEVOX/voicevox_core/main/LICENSE"
) as res:
licenses.append(
License(
name="VOICEVOX CORE",
version=None,
license="MIT license",
text=res.read().decode(),
)
)
# VOICEVOX ENGINE
with urllib.request.urlopen(
"https://raw.githubusercontent.com/VOICEVOX/voicevox_engine/master/LGPL_LICENSE"
) as res:
licenses.append(
License(
name="VOICEVOX ENGINE",
version=None,
license="LGPL license",
text=res.read().decode(),
)
)
# world
with urllib.request.urlopen(
"https://raw.githubusercontent.com/mmorise/World/master/LICENSE.txt"
) as res:
licenses.append(
License(
name="world",
version=None,
license="Modified BSD license",
text=res.read().decode(),
)
)
# pytorch
with urllib.request.urlopen(
"https://raw.githubusercontent.com/pytorch/pytorch/master/LICENSE"
) as res:
licenses.append(
License(
name="PyTorch",
version="1.9.0",
license="BSD-style license",
text=res.read().decode(),
)
)
# onnxruntime
with urllib.request.urlopen(
"https://raw.githubusercontent.com/microsoft/onnxruntime/master/LICENSE"
) as res:
licenses.append(
License(
name="ONNX Runtime",
version="1.10.0",
license="MIT license",
text=res.read().decode(),
)
)
# Python
python_version = "3.7.12"
with urllib.request.urlopen(
f"https://raw.githubusercontent.com/python/cpython/v{python_version}/LICENSE"
) as res:
licenses.append(
License(
name="Python",
version=python_version,
license="Python Software Foundation License",
text=res.read().decode(),
)
)
# pip
licenses_json = json.loads(
subprocess.run(
"pip-licenses "
"--from=mixed "
"--format=json "
"--with-urls "
"--with-license-file "
"--no-license-path ",
shell=True,
capture_output=True,
check=True,
env=os.environ,
).stdout.decode()
)
for license_json in licenses_json:
license = License(
name=license_json["Name"],
version=license_json["Version"],
license=license_json["License"],
text=license_json["LicenseText"],
)
# FIXME: assert license type
if license.text == "UNKNOWN":
if license.name.lower() == "core" and license.version == "0.0.0":
continue
elif license.name.lower() == "nuitka":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/Nuitka/Nuitka/develop/LICENSE.txt"
) as res:
license.text = res.read().decode()
elif license.name.lower() == "pyopenjtalk":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/r9y9/pyopenjtalk/master/LICENSE.md"
) as res:
license.text = res.read().decode()
elif license.name.lower() == "python-multipart":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/andrew-d/python-multipart/master/LICENSE.txt" # noqa: B950
) as res:
license.text = res.read().decode()
elif license.name.lower() == "romkan":
with urllib.request.urlopen(
"https://raw.githubusercontent.com/soimort/python-romkan/master/LICENSE"
) as res:
license.text = res.read().decode()
elif license.name.lower() == "distlib":
with urllib.request.urlopen(
"https://bitbucket.org/pypa/distlib/raw/7d93712134b28401407da27382f2b6236c87623a/LICENSE.txt" # noqa: B950
) as res:
license.text = res.read().decode()
else:
# ライセンスがpypiに無い
raise Exception(f"No License info provided for {license.name}")
licenses.append(license)
# OpenBLAS
with urllib.request.urlopen(
"https://raw.githubusercontent.com/xianyi/OpenBLAS/develop/LICENSE"
) as res:
licenses.append(
License(
name="OpenBLAS",
version=None,
license="BSD 3-clause license",
text=res.read().decode(),
)
)
# libsndfile-binaries
with urllib.request.urlopen(
"https://raw.githubusercontent.com/bastibe/libsndfile-binaries/84cb164928f17c7ca0c1e5c40342c20ce2b90e8c/COPYING" # noqa: B950
) as res:
licenses.append(
License(
name="libsndfile-binaries",
version="1.0.28",
license="LGPL-2.1 license",
text=res.read().decode(),
)
)
# libogg
with urllib.request.urlopen(
"https://raw.githubusercontent.com/xiph/ogg/v1.3.2/COPYING"
) as res:
licenses.append(
License(
name="libogg",
version="1.3.2",
license="BSD 3-clause license",
text=res.read().decode(),
)
)
# libvorbis
with urllib.request.urlopen(
"https://raw.githubusercontent.com/xiph/vorbis/v1.3.5/COPYING"
) as res:
licenses.append(
License(
name="libvorbis",
version="1.3.5",
license="BSD 3-clause license",
text=res.read().decode(),
)
)
# libflac
with urllib.request.urlopen(
"https://raw.githubusercontent.com/xiph/flac/1.3.2/COPYING.Xiph"
) as res:
licenses.append(
License(
name="FLAC",
version="1.3.2",
license="Xiph.org's BSD-like license",
text=res.read().decode(),
)
)
# cuda
# license text from CUDA 11.1.1
# https://developer.nvidia.com/cuda-11.1.1-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal # noqa: B950
# https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_471.41_win10.exe # noqa: B950
# cuda_11.1.1_456.81_win10.exe (cuda_documentation/Doc/EULA.txt)
licenses.append(
License(
name="CUDA Toolkit",
version="11.1.1",
license=None,
text=Path("docs/licenses/cuda/EULA.txt").read_text(encoding="utf8"),
)
)
# cudnn
# license text from
# cuDNN v7.6.5 (November 18th, 2019), for CUDA 10.2, cuDNN Library for Windows 10
# https://developer.nvidia.com/rdp/cudnn-archive # noqa: B950
# https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/cudnn-10.2-windows10-x64-v7.6.5.32.zip # noqa: B950
# cudnn-10.2-windows10-x64-v7.6.5.32.zip (cuda/NVIDIA_SLA_cuDNN_Support.txt)
licenses.append(
License(
name="cuDNN",
version="7.6.5",
license=None,
text=Path("docs/licenses/cuda/NVIDIA_SLA_cuDNN_Support.txt").read_text(
encoding="utf8"
),
)
)
return licenses
if __name__ == "__main__":
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output_path", type=str)
args = parser.parse_args()
output_path = args.output_path
licenses = generate_licenses()
# dump
out = Path(output_path).open("w") if output_path else sys.stdout
json.dump(
[asdict(license) for license in licenses],
out,
)