aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__main__.py20
-rwxr-xr-xpackaging/create_zipapp.py22
-rwxr-xr-xrun_meson_command_tests.py5
3 files changed, 25 insertions, 22 deletions
diff --git a/__main__.py b/__main__.py
deleted file mode 100644
index 27cd4c0..0000000
--- a/__main__.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright 2016 The Meson development team
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-
-# http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from mesonbuild import mesonmain
-import sys
-
-sys.exit(mesonmain.main())
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)
diff --git a/run_meson_command_tests.py b/run_meson_command_tests.py
index 7bc6185..795e545 100755
--- a/run_meson_command_tests.py
+++ b/run_meson_command_tests.py
@@ -193,9 +193,10 @@ class CommandTests(unittest.TestCase):
def test_meson_zipapp(self):
if is_windows():
raise unittest.SkipTest('NOT IMPLEMENTED')
- source = Path(__file__).resolve().parent.as_posix()
+ source = Path(__file__).resolve().parent
target = self.tmpdir / 'meson.pyz'
- zipapp.create_archive(source=source, target=target, interpreter=python_command[0], main=None)
+ script = source / 'packaging' / 'create_zipapp.py'
+ self._run([script.as_posix(), source, '--outfile', target, '--interpreter', python_command[0]])
self._run([target.as_posix(), '--help'])