summaryrefslogtreecommitdiff
path: root/python/scripts/main.py
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-11-29 21:39:59 -0800
committerDan Willemsen <dwillemsen@google.com>2019-02-15 14:33:59 -0800
commit707542f2989751e9a834e5d0bd30dc23cbcc8d16 (patch)
tree7a817e7fb8bdf60abfb85d3d8f4194839f7a5528 /python/scripts/main.py
parent7b88d7c9f6a1b5c8c50a581bb16e685be4ecd0d6 (diff)
Simplify python launcher, use __main__.py
Uses more python rather than C++, and skips less of Py_Main. Test: build/soong/python/tests/runtests.sh Change-Id: I03997d88e2e16047c96bb4e00e530229c42b3325
Diffstat (limited to 'python/scripts/main.py')
-rw-r--r--python/scripts/main.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/scripts/main.py b/python/scripts/main.py
new file mode 100644
index 000000000..225dbe4c1
--- /dev/null
+++ b/python/scripts/main.py
@@ -0,0 +1,12 @@
+import runpy
+import sys
+
+sys.argv[0] = __loader__.archive
+
+# Set sys.executable to None. The real executable is available as
+# sys.argv[0], and too many things assume sys.executable is a regular Python
+# binary, which isn't available. By setting it to None we get clear errors
+# when people try to use it.
+sys.executable = None
+
+runpy._run_module_as_main("ENTRY_POINT", alter_argv=False)