blob: e59858196249af03de285e14055cec10296fc39f [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:
162 yield from in_build("python.exe", new_name="python")
163 yield from in_build("pythonw.exe", new_name="pythonw")
164
165 yield from in_build(PYTHON_DLL_NAME)
166
167 if ns.include_launchers and ns.include_appxmanifest:
168 if ns.include_pip:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700169 yield from in_build("python_uwp.exe", new_name="pip{}".format(VER_DOT))
Steve Dower0cd63912018-12-10 18:52:57 -0800170 if ns.include_idle:
Steve Dower1fab9cb2019-08-07 10:49:40 -0700171 yield from in_build("pythonw_uwp.exe", new_name="idle{}".format(VER_DOT))
Steve Dower0cd63912018-12-10 18:52:57 -0800172
173 if ns.include_stable:
174 yield from in_build(PYTHON_STABLE_DLL_NAME)
175
176 for dest, src in rglob(ns.build, "vcruntime*.dll"):
177 yield dest, src
178
Steve Dower21a92f82019-06-14 08:29:20 -0700179 yield "LICENSE.txt", ns.build / "LICENSE.txt"
Steve Dower28f6cb32019-01-22 10:49:52 -0800180
Steve Dower0cd63912018-12-10 18:52:57 -0800181 for dest, src in rglob(ns.build, ("*.pyd", "*.dll")):
182 if src.stem.endswith("_d") != bool(ns.debug) and src not in REQUIRED_DLLS:
183 continue
184 if src in EXCLUDE_FROM_PYDS:
185 continue
186 if src in TEST_PYDS_ONLY and not ns.include_tests:
187 continue
188 if src in TCLTK_PYDS_ONLY and not ns.include_tcltk:
189 continue
190
191 yield from in_build(src.name, dest="" if ns.flat_dlls else "DLLs/")
192
193 if ns.zip_lib:
194 zip_name = PYTHON_ZIP_NAME
195 yield zip_name, ns.temp / zip_name
196 else:
197 for dest, src in get_lib_layout(ns):
198 yield "Lib/{}".format(dest), src
199
200 if ns.include_venv:
201 yield from in_build("venvlauncher.exe", "Lib/venv/scripts/nt/", "python")
202 yield from in_build("venvwlauncher.exe", "Lib/venv/scripts/nt/", "pythonw")
203
204 if ns.include_tools:
205
206 def _c(d):
207 if d.is_dir():
208 return d in TOOLS_DIRS
209 return d in TOOLS_FILES
210
211 for dest, src in rglob(ns.source / "Tools", "**/*", _c):
212 yield "Tools/{}".format(dest), src
213
214 if ns.include_underpth:
215 yield PYTHON_PTH_NAME, ns.temp / PYTHON_PTH_NAME
216
217 if ns.include_dev:
218
219 def _c(d):
220 if d.is_dir():
221 return d.name != "internal"
222 return True
223
224 for dest, src in rglob(ns.source / "Include", "**/*.h", _c):
225 yield "include/{}".format(dest), src
226 src = ns.source / "PC" / "pyconfig.h"
227 yield "include/pyconfig.h", src
228
229 for dest, src in get_tcltk_lib(ns):
230 yield dest, src
231
232 if ns.include_pip:
Steve Dower21a92f82019-06-14 08:29:20 -0700233 for dest, src in get_pip_layout(ns):
Steve Dower123536f2019-07-24 15:13:22 -0700234 if not isinstance(src, tuple) and (
Steve Dower21a92f82019-06-14 08:29:20 -0700235 src in EXCLUDE_FROM_LIB or src in EXCLUDE_FROM_PACKAGED_LIB
236 ):
237 continue
238 yield dest, src
Steve Dower0cd63912018-12-10 18:52:57 -0800239
240 if ns.include_chm:
241 for dest, src in rglob(ns.doc_build / "htmlhelp", PYTHON_CHM_NAME):
242 yield "Doc/{}".format(dest), src
243
244 if ns.include_html_doc:
245 for dest, src in rglob(ns.doc_build / "html", "**/*"):
246 yield "Doc/html/{}".format(dest), src
247
248 if ns.include_props:
249 for dest, src in get_props_layout(ns):
250 yield dest, src
251
Steve Dower21a92f82019-06-14 08:29:20 -0700252 if ns.include_nuspec:
253 for dest, src in get_nuspec_layout(ns):
254 yield dest, src
255
Steve Dower0cd63912018-12-10 18:52:57 -0800256 for dest, src in get_appx_layout(ns):
257 yield dest, src
258
259 if ns.include_cat:
260 if ns.flat_dlls:
261 yield ns.include_cat.name, ns.include_cat
262 else:
263 yield "DLLs/{}".format(ns.include_cat.name), ns.include_cat
264
265
Steve Dower872bd2b2019-01-08 02:38:01 -0800266def _compile_one_py(src, dest, name, optimize, checked=True):
Steve Dower0cd63912018-12-10 18:52:57 -0800267 import py_compile
268
269 if dest is not None:
270 dest = str(dest)
271
Steve Dower872bd2b2019-01-08 02:38:01 -0800272 mode = (
273 py_compile.PycInvalidationMode.CHECKED_HASH
274 if checked
275 else py_compile.PycInvalidationMode.UNCHECKED_HASH
276 )
277
Steve Dower0cd63912018-12-10 18:52:57 -0800278 try:
279 return Path(
280 py_compile.compile(
281 str(src),
282 dest,
283 str(name),
284 doraise=True,
285 optimize=optimize,
Steve Dower872bd2b2019-01-08 02:38:01 -0800286 invalidation_mode=mode,
Steve Dower0cd63912018-12-10 18:52:57 -0800287 )
288 )
289 except py_compile.PyCompileError:
290 log_warning("Failed to compile {}", src)
291 return None
292
Bill Collinsc4cda432019-07-25 22:36:58 +0100293# name argument added to address bpo-37641
294def _py_temp_compile(src, name, ns, dest_dir=None, checked=True):
Steve Dower0cd63912018-12-10 18:52:57 -0800295 if not ns.precompile or src not in PY_FILES or src.parent in DATA_DIRS:
296 return None
Bill Collinsc4cda432019-07-25 22:36:58 +0100297 dest = (dest_dir or ns.temp) / (src.stem + ".pyc")
Steve Dower21a92f82019-06-14 08:29:20 -0700298 return _compile_one_py(
Bill Collinsc4cda432019-07-25 22:36:58 +0100299 src, dest, name, optimize=2, checked=checked
Steve Dower21a92f82019-06-14 08:29:20 -0700300 )
Steve Dower0cd63912018-12-10 18:52:57 -0800301
302
Steve Dower872bd2b2019-01-08 02:38:01 -0800303def _write_to_zip(zf, dest, src, ns, checked=True):
Bill Collinsc4cda432019-07-25 22:36:58 +0100304 pyc = _py_temp_compile(src, dest, ns, checked=checked)
Steve Dower0cd63912018-12-10 18:52:57 -0800305 if pyc:
306 try:
307 zf.write(str(pyc), dest.with_suffix(".pyc"))
308 finally:
309 try:
310 pyc.unlink()
311 except:
312 log_exception("Failed to delete {}", pyc)
313 return
314
315 if src in LIB2TO3_GRAMMAR_FILES:
316 from lib2to3.pgen2.driver import load_grammar
317
318 tmp = ns.temp / src.name
319 try:
320 shutil.copy(src, tmp)
321 load_grammar(str(tmp))
322 for f in ns.temp.glob(src.stem + "*.pickle"):
323 zf.write(str(f), str(dest.parent / f.name))
324 try:
325 f.unlink()
326 except:
327 log_exception("Failed to delete {}", f)
328 except:
329 log_exception("Failed to compile {}", src)
330 finally:
331 try:
332 tmp.unlink()
333 except:
334 log_exception("Failed to delete {}", tmp)
335
336 zf.write(str(src), str(dest))
337
338
339def generate_source_files(ns):
340 if ns.zip_lib:
341 zip_name = PYTHON_ZIP_NAME
342 zip_path = ns.temp / zip_name
343 if zip_path.is_file():
344 zip_path.unlink()
345 elif zip_path.is_dir():
346 log_error(
347 "Cannot create zip file because a directory exists by the same name"
348 )
349 return
350 log_info("Generating {} in {}", zip_name, ns.temp)
351 ns.temp.mkdir(parents=True, exist_ok=True)
352 with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
353 for dest, src in get_lib_layout(ns):
Steve Dower872bd2b2019-01-08 02:38:01 -0800354 _write_to_zip(zf, dest, src, ns, checked=False)
Steve Dower0cd63912018-12-10 18:52:57 -0800355
356 if ns.include_underpth:
357 log_info("Generating {} in {}", PYTHON_PTH_NAME, ns.temp)
358 ns.temp.mkdir(parents=True, exist_ok=True)
359 with open(ns.temp / PYTHON_PTH_NAME, "w", encoding="utf-8") as f:
360 if ns.zip_lib:
361 print(PYTHON_ZIP_NAME, file=f)
362 if ns.include_pip:
363 print("packages", file=f)
364 else:
365 print("Lib", file=f)
366 print("Lib/site-packages", file=f)
367 if not ns.flat_dlls:
368 print("DLLs", file=f)
369 print(".", file=f)
370 print(file=f)
371 print("# Uncomment to run site.main() automatically", file=f)
372 print("#import site", file=f)
373
Steve Dower0cd63912018-12-10 18:52:57 -0800374 if ns.include_pip:
Steve Dower21a92f82019-06-14 08:29:20 -0700375 log_info("Extracting pip")
376 extract_pip_files(ns)
Steve Dower0cd63912018-12-10 18:52:57 -0800377
378
379def _create_zip_file(ns):
380 if not ns.zip:
381 return None
382
383 if ns.zip.is_file():
384 try:
385 ns.zip.unlink()
386 except OSError:
387 log_exception("Unable to remove {}", ns.zip)
388 sys.exit(8)
389 elif ns.zip.is_dir():
390 log_error("Cannot create ZIP file because {} is a directory", ns.zip)
391 sys.exit(8)
392
393 ns.zip.parent.mkdir(parents=True, exist_ok=True)
394 return zipfile.ZipFile(ns.zip, "w", zipfile.ZIP_DEFLATED)
395
396
397def copy_files(files, ns):
398 if ns.copy:
399 ns.copy.mkdir(parents=True, exist_ok=True)
400
401 try:
402 total = len(files)
403 except TypeError:
404 total = None
405 count = 0
406
407 zip_file = _create_zip_file(ns)
408 try:
409 need_compile = []
410 in_catalog = []
411
412 for dest, src in files:
413 count += 1
414 if count % 10 == 0:
415 if total:
416 log_info("Processed {:>4} of {} files", count, total)
417 else:
418 log_info("Processed {} files", count)
419 log_debug("Processing {!s}", src)
420
Steve Dower21a92f82019-06-14 08:29:20 -0700421 if isinstance(src, tuple):
422 src, content = src
423 if ns.copy:
424 log_debug("Copy {} -> {}", src, ns.copy / dest)
425 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
426 with open(ns.copy / dest, "wb") as f:
427 f.write(content)
428 if ns.zip:
429 log_debug("Zip {} into {}", src, ns.zip)
430 zip_file.writestr(str(dest), content)
431 continue
432
Steve Dower0cd63912018-12-10 18:52:57 -0800433 if (
434 ns.precompile
435 and src in PY_FILES
436 and src not in EXCLUDE_FROM_COMPILE
437 and src.parent not in DATA_DIRS
438 and os.path.normcase(str(dest)).startswith(os.path.normcase("Lib"))
439 ):
440 if ns.copy:
441 need_compile.append((dest, ns.copy / dest))
442 else:
443 (ns.temp / "Lib" / dest).parent.mkdir(parents=True, exist_ok=True)
Paul Monsonf4e56612019-04-12 09:55:57 -0700444 copy_if_modified(src, ns.temp / "Lib" / dest)
Steve Dower0cd63912018-12-10 18:52:57 -0800445 need_compile.append((dest, ns.temp / "Lib" / dest))
446
447 if src not in EXCLUDE_FROM_CATALOG:
448 in_catalog.append((src.name, src))
449
450 if ns.copy:
451 log_debug("Copy {} -> {}", src, ns.copy / dest)
452 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
453 try:
Paul Monsonf4e56612019-04-12 09:55:57 -0700454 copy_if_modified(src, ns.copy / dest)
Steve Dower0cd63912018-12-10 18:52:57 -0800455 except shutil.SameFileError:
456 pass
457
458 if ns.zip:
459 log_debug("Zip {} into {}", src, ns.zip)
460 zip_file.write(src, str(dest))
461
462 if need_compile:
463 for dest, src in need_compile:
464 compiled = [
465 _compile_one_py(src, None, dest, optimize=0),
466 _compile_one_py(src, None, dest, optimize=1),
467 _compile_one_py(src, None, dest, optimize=2),
468 ]
469 for c in compiled:
470 if not c:
471 continue
472 cdest = Path(dest).parent / Path(c).relative_to(src.parent)
473 if ns.zip:
474 log_debug("Zip {} into {}", c, ns.zip)
475 zip_file.write(c, str(cdest))
476 in_catalog.append((cdest.name, cdest))
477
478 if ns.catalog:
479 # Just write out the CDF now. Compilation and signing is
480 # an extra step
481 log_info("Generating {}", ns.catalog)
482 ns.catalog.parent.mkdir(parents=True, exist_ok=True)
483 write_catalog(ns.catalog, in_catalog)
484
485 finally:
486 if zip_file:
487 zip_file.close()
488
489
490def main():
491 parser = argparse.ArgumentParser()
492 parser.add_argument("-v", help="Increase verbosity", action="count")
493 parser.add_argument(
494 "-s",
495 "--source",
496 metavar="dir",
497 help="The directory containing the repository root",
498 type=Path,
499 default=None,
500 )
501 parser.add_argument(
502 "-b", "--build", metavar="dir", help="Specify the build directory", type=Path
503 )
504 parser.add_argument(
505 "--doc-build",
506 metavar="dir",
507 help="Specify the docs build directory",
508 type=Path,
509 default=None,
510 )
511 parser.add_argument(
512 "--copy",
513 metavar="directory",
514 help="The name of the directory to copy an extracted layout to",
515 type=Path,
516 default=None,
517 )
518 parser.add_argument(
519 "--zip",
520 metavar="file",
521 help="The ZIP file to write all files to",
522 type=Path,
523 default=None,
524 )
525 parser.add_argument(
526 "--catalog",
527 metavar="file",
528 help="The CDF file to write catalog entries to",
529 type=Path,
530 default=None,
531 )
532 parser.add_argument(
533 "--log",
534 metavar="file",
535 help="Write all operations to the specified file",
536 type=Path,
537 default=None,
538 )
539 parser.add_argument(
540 "-t",
541 "--temp",
542 metavar="file",
543 help="A temporary working directory",
544 type=Path,
545 default=None,
546 )
547 parser.add_argument(
548 "-d", "--debug", help="Include debug build", action="store_true"
549 )
550 parser.add_argument(
551 "-p",
552 "--precompile",
553 help="Include .pyc files instead of .py",
554 action="store_true",
555 )
556 parser.add_argument(
557 "-z", "--zip-lib", help="Include library in a ZIP file", action="store_true"
558 )
559 parser.add_argument(
560 "--flat-dlls", help="Does not create a DLLs directory", action="store_true"
561 )
562 parser.add_argument(
563 "-a",
564 "--include-all",
565 help="Include all optional components",
566 action="store_true",
567 )
568 parser.add_argument(
569 "--include-cat",
570 metavar="file",
571 help="Specify the catalog file to include",
572 type=Path,
573 default=None,
574 )
575 for opt, help in get_argparse_options():
576 parser.add_argument(opt, help=help, action="store_true")
577
578 ns = parser.parse_args()
579 update_presets(ns)
580
581 ns.source = ns.source or (Path(__file__).resolve().parent.parent.parent)
582 ns.build = ns.build or Path(sys.executable).parent
583 ns.temp = ns.temp or Path(tempfile.mkdtemp())
584 ns.doc_build = ns.doc_build or (ns.source / "Doc" / "build")
585 if not ns.source.is_absolute():
586 ns.source = (Path.cwd() / ns.source).resolve()
587 if not ns.build.is_absolute():
588 ns.build = (Path.cwd() / ns.build).resolve()
589 if not ns.temp.is_absolute():
590 ns.temp = (Path.cwd() / ns.temp).resolve()
591 if not ns.doc_build.is_absolute():
592 ns.doc_build = (Path.cwd() / ns.doc_build).resolve()
593 if ns.include_cat and not ns.include_cat.is_absolute():
594 ns.include_cat = (Path.cwd() / ns.include_cat).resolve()
595
596 if ns.copy and not ns.copy.is_absolute():
597 ns.copy = (Path.cwd() / ns.copy).resolve()
598 if ns.zip and not ns.zip.is_absolute():
599 ns.zip = (Path.cwd() / ns.zip).resolve()
600 if ns.catalog and not ns.catalog.is_absolute():
601 ns.catalog = (Path.cwd() / ns.catalog).resolve()
602
603 configure_logger(ns)
604
605 log_info(
606 """OPTIONS
607Source: {ns.source}
608Build: {ns.build}
609Temp: {ns.temp}
610
611Copy to: {ns.copy}
612Zip to: {ns.zip}
613Catalog: {ns.catalog}""",
614 ns=ns,
615 )
616
617 if ns.include_idle and not ns.include_tcltk:
618 log_warning("Assuming --include-tcltk to support --include-idle")
619 ns.include_tcltk = True
620
621 try:
622 generate_source_files(ns)
623 files = list(get_layout(ns))
624 copy_files(files, ns)
625 except KeyboardInterrupt:
626 log_info("Interrupted by Ctrl+C")
627 return 3
628 except SystemExit:
629 raise
630 except:
631 log_exception("Unhandled error")
632
633 if error_was_logged():
634 log_error("Errors occurred.")
635 return 1
636
637
638if __name__ == "__main__":
639 sys.exit(int(main() or 0))