|
7 | 7 | import os |
8 | 8 | import tempfile |
9 | 9 |
|
| 10 | +from itertools import chain |
10 | 11 | from pathlib import Path |
11 | 12 | from zipfile import ZipFile, ZIP_DEFLATED |
12 | 13 | import subprocess |
|
42 | 43 | } |
43 | 44 |
|
44 | 45 | EXCLUDE_FILE_FROM_LIBS = { |
| 46 | + 'liblzma', |
45 | 47 | 'ssleay', |
46 | 48 | 'libeay', |
47 | 49 | 'python3stub', |
@@ -77,6 +79,10 @@ def include_in_lib(p): |
77 | 79 | if name in EXCLUDE_FILE_FROM_LIBRARY: |
78 | 80 | return False |
79 | 81 |
|
| 82 | + # Special code is included below to patch this file back in |
| 83 | + if [d.lower() for d in p.parts[-3:]] == ['distutils', 'command', '__init__.py']: |
| 84 | + return False |
| 85 | + |
80 | 86 | suffix = p.suffix.lower() |
81 | 87 | return suffix not in {'.pyc', '.pyo', '.exe'} |
82 | 88 |
|
@@ -173,7 +179,7 @@ def rglob(root, pattern, condition): |
173 | 179 | def main(): |
174 | 180 | parser = argparse.ArgumentParser() |
175 | 181 | parser.add_argument('-s', '--source', metavar='dir', help='The directory containing the repository root', type=Path) |
176 | | - parser.add_argument('-o', '--out', metavar='file', help='The name of the output self-extracting archive', type=Path, default=None) |
| 182 | + parser.add_argument('-o', '--out', metavar='file', help='The name of the output archive', type=Path, default=None) |
177 | 183 | parser.add_argument('-t', '--temp', metavar='dir', help='A directory to temporarily extract files into', type=Path, default=None) |
178 | 184 | parser.add_argument('-e', '--embed', help='Create an embedding layout', action='store_true', default=False) |
179 | 185 | parser.add_argument('-a', '--arch', help='Specify the architecture to use (win32/amd64)', type=str, default="win32") |
@@ -207,8 +213,15 @@ def main(): |
207 | 213 |
|
208 | 214 | try: |
209 | 215 | for t, s, p, c in layout: |
210 | | - s = source / s.replace("$arch", arch) |
211 | | - copied = copy_to_layout(temp / t.rstrip('/'), rglob(s, p, c)) |
| 216 | + fs = source / s.replace("$arch", arch) |
| 217 | + files = rglob(fs, p, c) |
| 218 | + extra_files = [] |
| 219 | + if s == 'Lib' and p == '**/*': |
| 220 | + extra_files.append(( |
| 221 | + source / 'tools' / 'msi' / 'distutils.command.__init__.py', |
| 222 | + Path('distutils') / 'command' / '__init__.py' |
| 223 | + )) |
| 224 | + copied = copy_to_layout(temp / t.rstrip('/'), chain(files, extra_files)) |
212 | 225 | print('Copied {} files'.format(copied)) |
213 | 226 |
|
214 | 227 | if ns.embed: |
|
0 commit comments