Browse Source

Fix __main__.py for zipapp to work

0a035de removed main from meson.py breaking the call from __main__.py.
This causes zipapps to fail, since the call to meson.main() fails.

Copying the invocation from meson.py fixes this issue.

Additionally, add a test to run_meson_command_tests.py that
builds a zipapp from the source and attempts executing this
zipapp with --help to ensure that the resulting zipapp is
properly executable.
Christoph Burger-Scheidlin 1 year ago
parent
commit
e4a83e47d4
2 changed files with 11 additions and 2 deletions
  1. 2
    2
      __main__.py
  2. 9
    0
      run_meson_command_tests.py

+ 2
- 2
__main__.py View File

@@ -14,7 +14,7 @@
14 14
 # See the License for the specific language governing permissions and
15 15
 # limitations under the License.
16 16
 
17
-import meson
17
+from mesonbuild import mesonmain
18 18
 import sys
19 19
 
20
-sys.exit(meson.main())
20
+sys.exit(mesonmain.main())

+ 9
- 0
run_meson_command_tests.py View File

@@ -18,6 +18,7 @@ import os
18 18
 import tempfile
19 19
 import unittest
20 20
 import subprocess
21
+import zipapp
21 22
 from pathlib import Path
22 23
 
23 24
 from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows
@@ -182,5 +183,13 @@ class CommandTests(unittest.TestCase):
182 183
     def test_meson_exe_windows(self):
183 184
         raise unittest.SkipTest('NOT IMPLEMENTED')
184 185
 
186
+    def test_meson_zipapp(self):
187
+        if is_windows():
188
+            raise unittest.SkipTest('NOT IMPLEMENTED')
189
+        source = Path(__file__).resolve().parent.as_posix()
190
+        target = self.tmpdir / 'meson.pyz'
191
+        zipapp.create_archive(source=source, target=target, interpreter=python_command[0], main=None)
192
+        self._run([target.as_posix(), '--help'])
193
+
185 194
 if __name__ == '__main__':
186 195
     unittest.main(buffer=True)

Loading…
Cancel
Save