summaryrefslogtreecommitdiffstats
path: root/packaging/create_zipapp.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /packaging/create_zipapp.py
parentInitial commit. (diff)
downloadmeson-upstream.tar.xz
meson-upstream.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/create_zipapp.py')
-rwxr-xr-xpackaging/create_zipapp.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/packaging/create_zipapp.py b/packaging/create_zipapp.py
new file mode 100755
index 0000000..9fd0f5b
--- /dev/null
+++ b/packaging/create_zipapp.py
@@ -0,0 +1,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)