23
23
import argparse
24
24
import os
25
25
import os .path
26
+ from pathlib import Path
26
27
import shutil
27
28
import subprocess
28
29
import sys
37
38
THIRD_PARTY_NAMESPACE ,
38
39
)
39
40
from stub_uploader .metadata import Metadata , read_metadata
41
+ from stub_uploader .ts_data import TypeshedData , read_typeshed_data
40
42
41
43
CHANGELOG = "CHANGELOG.md"
42
44
108
110
109
111
DESCRIPTION_OUTRO_TEMPLATE = """
110
112
See https://github.com/python/typeshed/blob/main/README.md for more details.
111
- This package was generated from typeshed commit `{commit}`.
113
+ This package was generated from typeshed commit `{commit}` and was tested
114
+ with mypy {ts_data.mypy_version}, pyright {ts_data.pyright_version}, and
115
+ pytype {ts_data.pytype_version}.
112
116
""" .strip ()
113
117
114
118
@@ -234,7 +238,11 @@ def add_partial_marker(package_data: dict[str, list[str]], stub_dir: str) -> Non
234
238
235
239
236
240
def generate_setup_file (
237
- build_data : BuildData , metadata : Metadata , version : str , commit : str
241
+ build_data : BuildData ,
242
+ ts_data : TypeshedData ,
243
+ metadata : Metadata ,
244
+ version : str ,
245
+ commit : str ,
238
246
) -> str :
239
247
"""Auto-generate a setup.py file for given distribution using a template."""
240
248
all_requirements = [
@@ -247,7 +255,7 @@ def generate_setup_file(
247
255
distribution = build_data .distribution ,
248
256
stub_distribution = metadata .stub_distribution ,
249
257
long_description = generate_long_description (
250
- build_data .distribution , commit , metadata
258
+ build_data .distribution , commit , ts_data , metadata
251
259
),
252
260
version = version ,
253
261
requires = all_requirements ,
@@ -257,7 +265,7 @@ def generate_setup_file(
257
265
258
266
259
267
def generate_long_description (
260
- distribution : str , commit : str , metadata : Metadata
268
+ distribution : str , commit : str , ts_data : TypeshedData , metadata : Metadata
261
269
) -> str :
262
270
extra_description = metadata .extra_description .strip ()
263
271
parts : list [str ] = []
@@ -280,7 +288,7 @@ def generate_long_description(
280
288
)
281
289
if metadata .partial :
282
290
parts .append (PARTIAL_STUBS_DESCRIPTION )
283
- parts .append (DESCRIPTION_OUTRO_TEMPLATE .format (commit = commit ))
291
+ parts .append (DESCRIPTION_OUTRO_TEMPLATE .format (commit = commit , ts_data = ts_data ))
284
292
return "\n \n " .join (parts )
285
293
286
294
@@ -294,6 +302,7 @@ def main(
294
302
Note: the caller should clean the temporary directory where wheel is
295
303
created after uploading it.
296
304
"""
305
+ ts_data = read_typeshed_data (Path (typeshed_dir ))
297
306
build_data = BuildData (typeshed_dir , distribution )
298
307
if build_dir :
299
308
tmpdir = build_dir
@@ -307,7 +316,7 @@ def main(
307
316
).stdout .strip ()
308
317
metadata = read_metadata (typeshed_dir , distribution )
309
318
with open (os .path .join (tmpdir , "setup.py" ), "w" ) as f :
310
- f .write (generate_setup_file (build_data , metadata , version , commit ))
319
+ f .write (generate_setup_file (build_data , ts_data , metadata , version , commit ))
311
320
copy_stubs (build_data .stub_dir , tmpdir )
312
321
copy_changelog (distribution , tmpdir )
313
322
current_dir = os .getcwd ()
0 commit comments