| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import argparse |
| 4 |
from pathlib import Path |
| 5 |
import shutil |
| 6 |
import sys |
| 7 |
import tempfile |
| 8 |
import zipapp |
| 9 |
|
| 10 |
parser = argparse.ArgumentParser() |
| 11 |
parser.add_argument('source', nargs='?', default='.', help='Source directory') |
| 12 |
parser.add_argument('--outfile', default='meson.pyz', help='Output file for the zipapp') |
| 13 |
parser.add_argument('--interpreter', default='/usr/bin/env python3', help='The name of the Python interpreter to use') |
| 14 |
parser.add_argument('--compress', action='store_true', default=False, help='Compress files') |
| 15 |
|
| 16 |
options = parser.parse_args(sys.argv[1:]) |
| 17 |
|
| 18 |
source = Path(options.source).resolve() |
| 19 |
|
| 20 |
with tempfile.TemporaryDirectory() as d: |
| 21 |
shutil.copy2(source / 'meson.py', Path(d, '__main__.py')) |
| 22 |
shutil.copytree(source / 'mesonbuild', Path(d, 'mesonbuild')) |
| 23 |
zipapp.create_archive(d, interpreter=options.interpreter, target=options.outfile, compressed=options.compress) |