blob: 07b7e6d57429718eeed54c7a441c4c5ef3ff667d [file] [log] [blame]
Steve Dower0cd63912018-12-10 18:52:57 -08001"""
2Generates a layout of Python for Windows from a build.
3
4See python make_layout.py --help for usage.
5"""
6
7__author__ = "Steve Dower <steve.dower@python.org>"
8__version__ = "3.8"
9
10import argparse
11import functools
12import os
13import re
14import shutil
15import subprocess
16import sys
17import tempfile
18import zipfile
19
20from pathlib import Path
21
22if __name__ == "__main__":
23 # Started directly, so enable relative imports
24 __path__ = [str(Path(__file__).resolve().parent)]
25
26from .support.appxmanifest import *
27from .support.catalog import *
28from .support.constants import *
29from .support.filesets import *
30from .support.logging import *
31from .support.options import *
32from .support.pip import *
33from .support.props import *
Steve Dower21a92f82019-06-14 08:29:20 -070034from .support.nuspec import *
Steve Dower0cd63912018-12-10 18:52:57 -080035
36BDIST_WININST_FILES_ONLY = FileNameSet("wininst-*", "bdist_wininst.py")
37BDIST_WININST_STUB = "PC/layout/support/distutils.command.bdist_wininst.py"
38
39TEST_PYDS_ONLY = FileStemSet("xxlimited", "_ctypes_test", "_test*")
40TEST_DIRS_ONLY = FileNameSet("test", "tests")
41
42IDLE_DIRS_ONLY = FileNameSet("idlelib")
43
44TCLTK_PYDS_ONLY = FileStemSet("tcl*", "tk*", "_tkinter")
45TCLTK_DIRS_ONLY = FileNameSet("tkinter", "turtledemo")
46TCLTK_FILES_ONLY = FileNameSet("turtle.py")
47
48VENV_DIRS_ONLY = FileNameSet("venv", "ensurepip")
49
Steve Dower59c2aa22018-12-27 12:44:25 -080050EXCLUDE_FROM_PYDS = FileStemSet("python*", "pyshellext", "vcruntime*")
Steve Dower0cd63912018-12-10 18:52:57 -080051EXCLUDE_FROM_LIB = FileNameSet("*.pyc", "__pycache__", "*.pickle")
52EXCLUDE_FROM_PACKAGED_LIB = FileNameSet("readme.txt")
53EXCLUDE_FROM_COMPILE = FileNameSet("badsyntax_*", "bad_*")
54EXCLUDE_FROM_CATALOG = FileSuffixSet(".exe", ".pyd", ".dll")
55
Paul Monson32119e12019-03-29 16:30:10 -070056REQUIRED_DLLS = FileStemSet("libcrypto*", "libssl*", "libffi*")
Steve Dower0cd63912018-12-10 18:52:57 -080057
58LIB2TO3_GRAMMAR_FILES = FileNameSet("Grammar.txt", "PatternGrammar.txt")
59
60PY_FILES = FileSuffixSet(".py")
61PYC_FILES = FileSuffixSet(".pyc")
62CAT_FILES = FileSuffixSet(".cat")
63CDF_FILES = FileSuffixSet(".cdf")
64
65DATA_DIRS = FileNameSet("data")
66
67TOOLS_DIRS = FileNameSet("scripts", "i18n", "pynche", "demo", "parser")
68TOOLS_FILES = FileSuffixSet(".py", ".pyw", ".txt")
69
Steve Dower21a92f82019-06-14 08:29:20 -070070
Paul Monsonf4e56612019-04-12 09:55:57 -070071def copy_if_modified(src, dest):
72 try:
73 dest_stat = os.stat(dest)
74 except FileNotFoundError:
75 do_copy = True
76 else:
77 src_stat = os.stat(src)
Steve Dower21a92f82019-06-14 08:29:20 -070078 do_copy = (
79 src_stat.st_mtime != dest_stat.st_mtime
80 or src_stat.st_size != dest_stat.st_size
81 )
Paul Monsonf4e56612019-04-12 09:55:57 -070082
83 if do_copy:
84 shutil.copy2(src, dest)
Steve Dower0cd63912018-12-10 18:52:57 -080085
Steve Dower21a92f82019-06-14 08:29:20 -070086
Steve Dower0cd63912018-12-10 18:52:57 -080087def get_lib_layout(ns):
88 def _c(f):
89 if f in EXCLUDE_FROM_LIB:
90 return False
91 if f.is_dir():
92 if f in TEST_DIRS_ONLY:
93 return ns.include_tests
94 if f in TCLTK_DIRS_ONLY:
95 return ns.include_tcltk
96 if f in IDLE_DIRS_ONLY:
97 return ns.include_idle
98 if f in VENV_DIRS_ONLY:
99 return ns.include_venv
100 else:
101 if f in TCLTK_FILES_ONLY:
102 return ns.include_tcltk
103 if f in BDIST_WININST_FILES_ONLY:
104 return ns.include_bdist_wininst
105 return True
106
107 for dest, src in rglob(ns.source / "Lib", "**/*", _c):
108 yield dest, src
109
110 if not ns.include_bdist_wininst:
111 src = ns.source / BDIST_WININST_STUB
112 yield Path("distutils/command/bdist_wininst.py"), src
113
114
115def get_tcltk_lib(ns):
116 if not ns.include_tcltk:
117 return
118
119 tcl_lib = os.getenv("TCL_LIBRARY")
120 if not tcl_lib or not os.path.isdir(tcl_lib):
121 try:
122 with open(ns.build / "TCL_LIBRARY.env", "r", encoding="utf-8-sig") as f:
123 tcl_lib = f.read().strip()
124 except FileNotFoundError:
125 pass
126 if not tcl_lib or not os.path.isdir(tcl_lib):
Steve Dower21a92f82019-06-14 08:29:20 -0700127 log_warning("Failed to find TCL_LIBRARY")
Steve Dower0cd63912018-12-10 18:52:57 -0800128 return
129
130 for dest, src in rglob(Path(tcl_lib).parent, "**/*"):
131 yield "tcl/{}".format(dest), src
132
133
134def get_layout(ns):
135 def in_build(f, dest="", new_name=None):
136 n, _, x = f.rpartition(".")
137 n = new_name or n
138 src = ns.build / f
139 if ns.debug and src not in REQUIRED_DLLS:
140 if not src.stem.endswith("_d"):
141 src = src.parent / (src.stem + "_d" + src.suffix)
142 if not n.endswith("_d"):
143 n += "_d"
144 f = n + "." + x
145 yield dest + n + "." + x, src
146 if ns.include_symbols:
147 pdb = src.with_suffix(".pdb")
148 if pdb.is_file():
149 yield dest + n + ".pdb", pdb
150 if ns.include_dev:
151 lib = src.with_suffix(".lib")
152 if lib.is_file():
153 yield "libs/" + n + ".lib", lib
154
155 if ns.include_appxmanifest:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700156 yield from in_build("python_uwp.exe", new_name="python{}".format(VER_DOT))
157 yield from in_build("pythonw_uwp.exe", new_name="pythonw{}".format(VER_DOT))
158 # For backwards compatibility, but we don't reference these ourselves.
Steve Dower0cd63912018-12-10 18:52:57 -0800159 yield from in_build("python_uwp.exe", new_name="python")
160 yield from in_build("pythonw_uwp.exe", new_name="pythonw")
161 else:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700162 yield from in_build("python.exe", new_name="python{}".format(VER_DOT))
163 yield from in_build("pythonw.exe", new_name="pythonw{}".format(VER_DOT))
164 # For backwards compatibility, but we don't reference these ourselves.
Steve Dower0cd63912018-12-10 18:52:57 -0800165 yield from in_build("python.exe", new_name="python")
166 yield from in_build("pythonw.exe", new_name="pythonw")
167
168 yield from in_build(PYTHON_DLL_NAME)
169
170 if ns.include_launchers and ns.include_appxmanifest:
171 if ns.include_pip:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700172 yield from in_build("python_uwp.exe", new_name="pip{}".format(VER_DOT))
Steve Dower0cd63912018-12-10 18:52:57 -0800173 if ns.include_idle:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700174 yield from in_build("pythonw_uwp.exe", new_name="idle{}".format(VER_DOT))
Steve Dower0cd63912018-12-10 18:52:57 -0800175
176 if ns.include_stable:
177 yield from in_build(PYTHON_STABLE_DLL_NAME)
178
179 for dest, src in rglob(ns.build, "vcruntime*.dll"):
180 yield dest, src
181
Steve Dower21a92f82019-06-14 08:29:20 -0700182 yield "LICENSE.txt", ns.build / "LICENSE.txt"
Steve Dower28f6cb32019-01-22 10:49:52 -0800183
Steve Dower0cd63912018-12-10 18:52:57 -0800184 for dest, src in rglob(ns.build, ("*.pyd", "*.dll")):
185 if src.stem.endswith("_d") != bool(ns.debug) and src not in REQUIRED_DLLS:
186 continue
187 if src in EXCLUDE_FROM_PYDS:
188 continue
189 if src in TEST_PYDS_ONLY and not ns.include_tests:
190 continue
191 if src in TCLTK_PYDS_ONLY and not ns.include_tcltk:
192 continue
193
194 yield from in_build(src.name, dest="" if ns.flat_dlls else "DLLs/")
195
196 if ns.zip_lib:
197 zip_name = PYTHON_ZIP_NAME
198 yield zip_name, ns.temp / zip_name
199 else:
200 for dest, src in get_lib_layout(ns):
201 yield "Lib/{}".format(dest), src
202
203 if ns.include_venv:
204 yield from in_build("venvlauncher.exe", "Lib/venv/scripts/nt/", "python")
205 yield from in_build("venvwlauncher.exe", "Lib/venv/scripts/nt/", "pythonw")
206
207 if ns.include_tools:
208
209 def _c(d):
210 if d.is_dir():
211 return d in TOOLS_DIRS
212 return d in TOOLS_FILES
213
214 for dest, src in rglob(ns.source / "Tools", "**/*", _c):
215 yield "Tools/{}".format(dest), src
216
217 if ns.include_underpth:
218 yield PYTHON_PTH_NAME, ns.temp / PYTHON_PTH_NAME
219
220 if ns.include_dev:
221
222 def _c(d):
223 if d.is_dir():
224 return d.name != "internal"
225 return True
226
227 for dest, src in rglob(ns.source / "Include", "**/*.h", _c):
228 yield "include/{}".format(dest), src
229 src = ns.source / "PC" / "pyconfig.h"
230 yield "include/pyconfig.h", src
231
232 for dest, src in get_tcltk_lib(ns):
233 yield dest, src
234
235 if ns.include_pip:
Steve Dower21a92f82019-06-14 08:29:20 -0700236 for dest, src in get_pip_layout(ns):
Steve Dower123536f2019-07-24 15:13:22 -0700237 if not isinstance(src, tuple) and (
Steve Dower21a92f82019-06-14 08:29:20 -0700238 src in EXCLUDE_FROM_LIB or src in EXCLUDE_FROM_PACKAGED_LIB
239 ):
240 continue
241 yield dest, src
Steve Dower0cd63912018-12-10 18:52:57 -0800242
243 if ns.include_chm:
244 for dest, src in rglob(ns.doc_build / "htmlhelp", PYTHON_CHM_NAME):
245 yield "Doc/{}".format(dest), src
246
247 if ns.include_html_doc:
248 for dest, src in rglob(ns.doc_build / "html", "**/*"):
249 yield "Doc/html/{}".format(dest), src
250
251 if ns.include_props:
252 for dest, src in get_props_layout(ns):
253 yield dest, src
254
Steve Dower21a92f82019-06-14 08:29:20 -0700255 if ns.include_nuspec:
256 for dest, src in get_nuspec_layout(ns):
257 yield dest, src
258
Steve Dower0cd63912018-12-10 18:52:57 -0800259 for dest, src in get_appx_layout(ns):
260 yield dest, src
261
262 if ns.include_cat:
263 if ns.flat_dlls:
264 yield ns.include_cat.name, ns.include_cat
265 else:
266 yield "DLLs/{}".format(ns.include_cat.name), ns.include_cat
267
268
Steve Dower872bd2b2019-01-08 02:38:01 -0800269def _compile_one_py(src, dest, name, optimize, checked=True):
Steve Dower0cd63912018-12-10 18:52:57 -0800270 import py_compile
271
272 if dest is not None:
273 dest = str(dest)
274
Steve Dower872bd2b2019-01-08 02:38:01 -0800275 mode = (
276 py_compile.PycInvalidationMode.CHECKED_HASH
277 if checked
278 else py_compile.PycInvalidationMode.UNCHECKED_HASH
279 )
280
Steve Dower0cd63912018-12-10 18:52:57 -0800281 try:
282 return Path(
283 py_compile.compile(
284 str(src),
285 dest,
286 str(name),
287 doraise=True,
288 optimize=optimize,
Steve Dower872bd2b2019-01-08 02:38:01 -0800289 invalidation_mode=mode,
Steve Dower0cd63912018-12-10 18:52:57 -0800290 )
291 )
292 except py_compile.PyCompileError:
293 log_warning("Failed to compile {}", src)
294 return None
295
Bill Collinsc4cda432019-07-25 22:36:58 +0100296# name argument added to address bpo-37641
297def _py_temp_compile(src, name, ns, dest_dir=None, checked=True):
Steve Dower0cd63912018-12-10 18:52:57 -0800298 if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS:
299 return None
Bill Collinsc4cda432019-07-25 22:36:58 +0100300 dest = (dest_dir or ns.temp) / (src.stem + ".pyc")
Steve Dower21a92f82019-06-14 08:29:20 -0700301 return _compile_one_py(
Bill Collinsc4cda432019-07-25 22:36:58 +0100302 src, dest, name, optimize=2, checked=checked
Steve Dower21a92f82019-06-14 08:29:20 -0700303 )
Steve Dower0cd63912018-12-10 18:52:57 -0800304
305
Steve Dower872bd2b2019-01-08 02:38:01 -0800306def _write_to_zip(zf, dest, src, ns, checked=True):
Bill Collinsc4cda432019-07-25 22:36:58 +0100307 pyc = _py_temp_compile(src, dest, ns, checked=checked)
Steve Dower0cd63912018-12-10 18:52:57 -0800308 if pyc:
309 try:
310 zf.write(str(pyc), dest.with_suffix(".pyc"))
311 finally:
312 try:
313 pyc.unlink()
314 except:
315 log_exception("Failed to delete {}", pyc)
316 return
317
318 if src in LIB2TO3_GRAMMAR_FILES:
319 from lib2to3.pgen2.driver import load_grammar
320
321 tmp = ns.temp / src.name
322 try:
323 shutil.copy(src, tmp)
324 load_grammar(str(tmp))
325 for f in ns.temp.glob(src.stem + "*.pickle"):
326 zf.write(str(f), str(dest.parent / f.name))
327 try:
328 f.unlink()
329 except:
330 log_exception("Failed to delete {}", f)
331 except:
332 log_exception("Failed to compile {}", src)
333 finally:
334 try:
335 tmp.unlink()
336 except:
337 log_exception("Failed to delete {}", tmp)
338
339 zf.write(str(src), str(dest))
340
341
342def generate_source_files(ns):
343 if ns.zip_lib:
344 zip_name = PYTHON_ZIP_NAME
345 zip_path = ns.temp / zip_name
346 if zip_path.is_file():
347 zip_path.unlink()
348 elif zip_path.is_dir():
349 log_error(
350 "Cannot create zip file because a directory exists by the same name"
351 )
352 return
353 log_info("Generating {} in {}", zip_name, ns.temp)
354 ns.temp.mkdir(parents=True, exist_ok=True)
355 with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
356 for dest, src in get_lib_layout(ns):
Steve Dower872bd2b2019-01-08 02:38:01 -0800357 _write_to_zip(zf, dest, src, ns, checked=False)
Steve Dower0cd63912018-12-10 18:52:57 -0800358
359 if ns.include_underpth:
360 log_info("Generating {} in {}", PYTHON_PTH_NAME, ns.temp)
361 ns.temp.mkdir(parents=True, exist_ok=True)
362 with open(ns.temp / PYTHON_PTH_NAME, "w", encoding="utf-8") as f:
363 if ns.zip_lib:
364 print(PYTHON_ZIP_NAME, file=f)
365 if ns.include_pip:
366 print("packages", file=f)
367 else:
368 print("Lib", file=f)
369 print("Lib/site-packages", file=f)
370 if not ns.flat_dlls:
371 print("DLLs", file=f)
372 print(".", file=f)
373 print(file=f)
374 print("# Uncomment to run site.main() automatically", file=f)
375 print("#import site", file=f)
376
Steve Dower0cd63912018-12-10 18:52:57 -0800377 if ns.include_pip:
Steve Dower21a92f82019-06-14 08:29:20 -0700378 log_info("Extracting pip")
379 extract_pip_files(ns)
Steve Dower0cd63912018-12-10 18:52:57 -0800380
381
382def _create_zip_file(ns):
383 if not ns.zip:
384 return None
385
386 if ns.zip.is_file():
387 try:
388 ns.zip.unlink()
389 except OSError:
390 log_exception("Unable to remove {}", ns.zip)
391 sys.exit(8)
392 elif ns.zip.is_dir():
393 log_error("Cannot create ZIP file because {} is a directory", ns.zip)
394 sys.exit(8)
395
396 ns.zip.parent.mkdir(parents=True, exist_ok=True)
397 return zipfile.ZipFile(ns.zip, "w", zipfile.ZIP_DEFLATED)
398
399
400def copy_files(files, ns):
401 if ns.copy:
402 ns.copy.mkdir(parents=True, exist_ok=True)
403
404 try:
405 total = len(files)
406 except TypeError:
407 total = None
408 count = 0
409
410 zip_file = _create_zip_file(ns)
411 try:
412 need_compile = []
413 in_catalog = []
414
415 for dest, src in files:
416 count += 1
417 if count % 10 == 0:
418 if total:
419 log_info("Processed {:>4} of {} files", count, total)
420 else:
421 log_info("Processed {} files", count)
422 log_debug("Processing {!s}", src)
423
Steve Dower21a92f82019-06-14 08:29:20 -0700424 if isinstance(src, tuple):
425 src, content = src
426 if ns.copy:
427 log_debug("Copy {} -> {}", src, ns.copy / dest)
428 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
429 with open(ns.copy / dest, "wb") as f:
430 f.write(content)
431 if ns.zip:
432 log_debug("Zip {} into {}", src, ns.zip)
433 zip_file.writestr(str(dest), content)
434 continue
435
Steve Dower0cd63912018-12-10 18:52:57 -0800436 if (
437 ns.precompile
438 and src in PY_FILES
439 and src not in EXCLUDE_FROM_COMPILE
440 and src.parent not in DATA_DIRS
441 and os.path.normcase(str(dest)).startswith(os.path.normcase("Lib"))
442 ):
443 if ns.copy:
444 need_compile.append((dest, ns.copy / dest))
445 else:
446 (ns.temp / "Lib" / dest).parent.mkdir(parents=True, exist_ok=True)
Paul Monsonf4e56612019-04-12 09:55:57 -0700447 copy_if_modified(src, ns.temp / "Lib" / dest)
Steve Dower0cd63912018-12-10 18:52:57 -0800448 need_compile.append((dest, ns.temp / "Lib" / dest))
449
450 if src not in EXCLUDE_FROM_CATALOG:
451 in_catalog.append((src.name, src))
452
453 if ns.copy:
454 log_debug("Copy {} -> {}", src, ns.copy / dest)
455 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
456 try:
Paul Monsonf4e56612019-04-12 09:55:57 -0700457 copy_if_modified(src, ns.copy / dest)
Steve Dower0cd63912018-12-10 18:52:57 -0800458 except shutil.SameFileError:
459 pass
460
461 if ns.zip:
462 log_debug("Zip {} into {}", src, ns.zip)
463 zip_file.write(src, str(dest))
464
465 if need_compile:
466 for dest, src in need_compile:
467 compiled = [
468 _compile_one_py(src, None, dest, optimize=0),
469 _compile_one_py(src, None, dest, optimize=1),
470 _compile_one_py(src, None, dest, optimize=2),
471 ]
472 for c in compiled:
473 if not c:
474 continue
475 cdest = Path(dest).parent / Path(c).relative_to(src.parent)
476 if ns.zip:
477 log_debug("Zip {} into {}", c, ns.zip)
478 zip_file.write(c, str(cdest))
479 in_catalog.append((cdest.name, cdest))
480
481 if ns.catalog:
482 # Just write out the CDF now. Compilation and signing is
483 # an extra step
484 log_info("Generating {}", ns.catalog)
485 ns.catalog.parent.mkdir(parents=True, exist_ok=True)
486 write_catalog(ns.catalog, in_catalog)
487
488 finally:
489 if zip_file:
490 zip_file.close()
491
492
493def main():
494 parser = argparse.ArgumentParser()
495 parser.add_argument("-v", help="Increase verbosity", action="count")
496 parser.add_argument(
497 "-s",
498 "--source",
499 metavar="dir",
500 help="The directory containing the repository root",
501 type=Path,
502 default=None,
503 )
504 parser.add_argument(
505 "-b", "--build", metavar="dir", help="Specify the build directory", type=Path
506 )
507 parser.add_argument(
508 "--doc-build",
509 metavar="dir",
510 help="Specify the docs build directory",
511 type=Path,
512 default=None,
513 )
514 parser.add_argument(
515 "--copy",
516 metavar="directory",
517 help="The name of the directory to copy an extracted layout to",
518 type=Path,
519 default=None,
520 )
521 parser.add_argument(
522 "--zip",
523 metavar="file",
524 help="The ZIP file to write all files to",
525 type=Path,
526 default=None,
527 )
528 parser.add_argument(
529 "--catalog",
530 metavar="file",
531 help="The CDF file to write catalog entries to",
532 type=Path,
533 default=None,
534 )
535 parser.add_argument(
536 "--log",
537 metavar="file",
538 help="Write all operations to the specified file",
539 type=Path,
540 default=None,
541 )
542 parser.add_argument(
543 "-t",
544 "--temp",
545 metavar="file",
546 help="A temporary working directory",
547 type=Path,
548 default=None,
549 )
550 parser.add_argument(
551 "-d", "--debug", help="Include debug build", action="store_true"
552 )
553 parser.add_argument(
554 "-p",
555 "--precompile",
556 help="Include .pyc files instead of .py",
557 action="store_true",
558 )
559 parser.add_argument(
560 "-z", "--zip-lib", help="Include library in a ZIP file", action="store_true"
561 )
562 parser.add_argument(
563 "--flat-dlls", help="Does not create a DLLs directory", action="store_true"
564 )
565 parser.add_argument(
566 "-a",
567 "--include-all",
568 help="Include all optional components",
569 action="store_true",
570 )
571 parser.add_argument(
572 "--include-cat",
573 metavar="file",
574 help="Specify the catalog file to include",
575 type=Path,
576 default=None,
577 )
578 for opt, help in get_argparse_options():
579 parser.add_argument(opt, help=help, action="store_true")
580
581 ns = parser.parse_args()
582 update_presets(ns)
583
584 ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent)
585 ns.build = ns.build or Path(sys.executable).parent
586 ns.temp = ns.temp or Path(tempfile.mkdtemp())
587 ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
588 if not ns.source.is_absolute():
589 ns.source = (Path.cwd() / ns.source).resolve()
590 if not ns.build.is_absolute():
591 ns.build = (Path.cwd() / ns.build).resolve()
592 if not ns.temp.is_absolute():
593 ns.temp = (Path.cwd() / ns.temp).resolve()
594 if not ns.doc_build.is_absolute():
595 ns.doc_build = (Path.cwd() / ns.doc_build).resolve()
596 if ns.include_cat and not ns.include_cat.is_absolute():
597 ns.include_cat = (Path.cwd() / ns.include_cat).resolve()
598
599 if ns.copy and not ns.copy.is_absolute():
600 ns.copy = (Path.cwd() / ns.copy).resolve()
601 if ns.zip and not ns.zip.is_absolute():
602 ns.zip = (Path.cwd() / ns.zip).resolve()
603 if ns.catalog and not ns.catalog.is_absolute():
604 ns.catalog = (Path.cwd() / ns.catalog).resolve()
605
606 configure_logger(ns)
607
608 log_info(
609 """OPTIONS
610Source: {ns.source}
611Build: {ns.build}
612Temp: {ns.temp}
613
614Copy to: {ns.copy}
615Zip to: {ns.zip}
616Catalog: {ns.catalog}""",
617 ns=ns,
618 )
619
620 if ns.include_idle and not ns.include_tcltk:
621 log_warning("Assuming --include-tcltk to support --include-idle")
622 ns.include_tcltk = True
623
624 try:
625 generate_source_files(ns)
626 files = list(get_layout(ns))
627 copy_files(files, ns)
628 except KeyboardInterrupt:
629 log_info("Interrupted by Ctrl+C")
630 return 3
631 except SystemExit:
632 raise
633 except:
634 log_exception("Unhandled error")
635
636 if error_was_logged():
637 log_error("Errors occurred.")
638 return 1
639
640
641if __name__ == "__main__":
642 sys.exit(int(main() or 0))