File: create_zipapp.py

package info (click to toggle)
meson 1.10.1-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 24,696 kB
  • sloc: python: 90,629; ansic: 7,377; cpp: 2,434; f90: 482; asm: 218; sh: 143; xml: 109; java: 97; cs: 62; objc: 33; lex: 13; fortran: 12; makefile: 10; yacc: 9; javascript: 6
file content (23 lines) | stat: -rwxr-xr-x 905 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3

import argparse
from pathlib import Path
import shutil
import sys
import tempfile
import zipapp

parser = argparse.ArgumentParser()
parser.add_argument('source', nargs='?', default='.', help='Source directory')
parser.add_argument('--outfile', default='meson.pyz', help='Output file for the zipapp')
parser.add_argument('--interpreter', default='/usr/bin/env python3', help='The name of the Python interpreter to use')
parser.add_argument('--compress', action='store_true', default=False, help='Compress files')

options = parser.parse_args(sys.argv[1:])

source = Path(options.source).resolve()

with tempfile.TemporaryDirectory() as d:
    shutil.copy2(source / 'meson.py', Path(d, '__main__.py'))
    shutil.copytree(source / 'mesonbuild', Path(d, 'mesonbuild'))
    zipapp.create_archive(d, interpreter=options.interpreter, target=options.outfile, compressed=options.compress)