Skip to content

Commit

Permalink
Fix __main__.py for zipapp to work
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cburger-scheidlin authored and nirbheek committed Aug 7, 2018
1 parent c9aea4e commit e4a83e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions __main__.py
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import meson
from mesonbuild import mesonmain
import sys

sys.exit(meson.main())
sys.exit(mesonmain.main())
9 changes: 9 additions & 0 deletions run_meson_command_tests.py
Expand Up @@ -18,6 +18,7 @@
import tempfile
import unittest
import subprocess
import zipapp
from pathlib import Path

from mesonbuild.mesonlib import windows_proof_rmtree, python_command, is_windows
Expand Down Expand Up @@ -182,5 +183,13 @@ def test_meson_installed(self):
def test_meson_exe_windows(self):
raise unittest.SkipTest('NOT IMPLEMENTED')

def test_meson_zipapp(self):
if is_windows():
raise unittest.SkipTest('NOT IMPLEMENTED')
source = Path(__file__).resolve().parent.as_posix()
target = self.tmpdir / 'meson.pyz'
zipapp.create_archive(source=source, target=target, interpreter=python_command[0], main=None)
self._run([target.as_posix(), '--help'])

if __name__ == '__main__':
unittest.main(buffer=True)

0 comments on commit e4a83e4

Please sign in to comment.