aboutsummaryrefslogtreecommitdiff
path: root/packaging
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2020-11-24 15:41:56 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2020-11-27 18:12:08 +0200
commit0fa808f7066d20047c0576da064bcc105053c401 (patch)
treef39a5784acc4d35a1075583e4a33ff8f3c53b03e /packaging
parentdf50123c058bd1e76c1b3230b4f27531f0adfe07 (diff)
downloadmeson-0fa808f7066d20047c0576da064bcc105053c401.zip
meson-0fa808f7066d20047c0576da064bcc105053c401.tar.gz
meson-0fa808f7066d20047c0576da064bcc105053c401.tar.bz2
Add script to create a zipapp.
Invoke create_zipapp.py from the root of the repository and it will create a minimal zipapp with only the mesonbuild module code and a __main__.py directly copied from meson.py The meson.py launcher already tracks the desired entry point, and its only other effect is to add the mesonbuild directory to the path if it exists, which it won't in the zipapp. So there's no need to duplicate this into another __main__.py
Diffstat (limited to 'packaging')
-rwxr-xr-xpackaging/create_zipapp.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/packaging/create_zipapp.py b/packaging/create_zipapp.py
new file mode 100755
index 0000000..4e018bf
--- /dev/null
+++ b/packaging/create_zipapp.py
@@ -0,0 +1,22 @@
+#!/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')
+
+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)