| 107 | |
| 108 | |
| 109 | def create_stdlib_zip( |
| 110 | args: argparse.Namespace, |
| 111 | *, |
| 112 | optimize: int = 0, |
| 113 | ) -> None: |
| 114 | def filterfunc(filename: str) -> bool: |
| 115 | pathname = pathlib.Path(filename).resolve() |
| 116 | return pathname not in args.omit_files_absolute |
| 117 | |
| 118 | with zipfile.PyZipFile( |
| 119 | args.output, |
| 120 | mode="w", |
| 121 | compression=args.compression, |
| 122 | optimize=optimize, |
| 123 | ) as pzf: |
| 124 | if args.compresslevel is not None: |
| 125 | pzf.compresslevel = args.compresslevel |
| 126 | pzf.writepy(args.sysconfig_data) |
| 127 | for entry in sorted(args.srcdir_lib.iterdir()): |
| 128 | entry = entry.resolve() |
| 129 | if entry.name == "__pycache__": |
| 130 | continue |
| 131 | if entry.name.endswith(".py") or entry.is_dir(): |
| 132 | # writepy() writes .pyc files (bytecode). |
| 133 | pzf.writepy(entry, filterfunc=filterfunc) |
| 134 | |
| 135 | |
| 136 | def detect_extension_modules(args: argparse.Namespace) -> dict[str, bool]: |