summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2019-11-04 19:21:04 -0800
committerDan Willemsen <dwillemsen@google.com>2019-11-04 19:48:19 -0800
commit8d4d7bee6d8bd398a07b0aec7043f6ee76769d4c (patch)
treed6b367bb76f9b41d337f2b3d91741d9bf6779f3b /python
parentf66a280354c015e9b3650c95db1e74062607ceb2 (diff)
Add python3 embedded launcher support
Test: m par_test{,3}; build/soong/python/tests/runtest.sh Change-Id: I9c0fac9e2947616fdeedbfc55026dc3065966e71
Diffstat (limited to 'python')
-rw-r--r--python/python.go25
-rw-r--r--python/tests/Android.bp16
-rwxr-xr-xpython/tests/runtest.sh8
-rw-r--r--python/tests/testpkg/par_test.py8
4 files changed, 49 insertions, 8 deletions
diff --git a/python/python.go b/python/python.go
index 1b606cbb9..c67c577dc 100644
--- a/python/python.go
+++ b/python/python.go
@@ -326,9 +326,24 @@ func (p *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
p.properties.Version.Py3.Libs)...)
if p.bootstrapper != nil && p.isEmbeddedLauncherEnabled(pyVersion3) {
- //TODO(nanzhang): Add embedded launcher for Python3.
- ctx.PropertyErrorf("version.py3.embedded_launcher",
- "is not supported yet for Python3.")
+ ctx.AddVariationDependencies(nil, pythonLibTag, "py3-stdlib")
+
+ launcherModule := "py3-launcher"
+ if p.bootstrapper.autorun() {
+ launcherModule = "py3-launcher-autorun"
+ }
+ ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherTag, launcherModule)
+
+ // Add py3-launcher shared lib dependencies. Ideally, these should be
+ // derived from the `shared_libs` property of "py3-launcher". However, we
+ // cannot read the property at this stage and it will be too late to add
+ // dependencies later.
+ ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherSharedLibTag, "libsqlite")
+
+ if ctx.Target().Os.Bionic() {
+ ctx.AddFarVariationDependencies(ctx.Target().Variations(), launcherSharedLibTag,
+ "libc", "libdl", "libm")
+ }
}
default:
panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
@@ -370,11 +385,11 @@ func (p *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Only Python binaries and test has non-empty bootstrapper.
if p.bootstrapper != nil {
p.walkTransitiveDeps(ctx)
- // TODO(nanzhang): Since embedded launcher is not supported for Python3 for now,
- // so we initialize "embedded_launcher" to false.
embeddedLauncher := false
if p.properties.Actual_version == pyVersion2 {
embeddedLauncher = p.isEmbeddedLauncherEnabled(pyVersion2)
+ } else {
+ embeddedLauncher = p.isEmbeddedLauncherEnabled(pyVersion3)
}
p.installSource = p.bootstrapper.bootstrap(ctx, p.properties.Actual_version,
embeddedLauncher, p.srcsPathMappings, p.srcsZip, p.depsSrcsZips)
diff --git a/python/tests/Android.bp b/python/tests/Android.bp
index 1f4305c41..c8bf42023 100644
--- a/python/tests/Android.bp
+++ b/python/tests/Android.bp
@@ -27,6 +27,22 @@ python_test_host {
},
py3: {
enabled: false,
+ embedded_launcher: true,
+ },
+ },
+}
+
+python_test_host {
+ name: "par_test3",
+ main: "par_test.py",
+ srcs: [
+ "par_test.py",
+ "testpkg/par_test.py",
+ ],
+
+ version: {
+ py3: {
+ embedded_launcher: true,
},
},
}
diff --git a/python/tests/runtest.sh b/python/tests/runtest.sh
index a319558ff..1ecdebc9e 100755
--- a/python/tests/runtest.sh
+++ b/python/tests/runtest.sh
@@ -23,8 +23,8 @@ if [ -z $ANDROID_HOST_OUT ]; then
exit 1
fi
-if [ ! -f $ANDROID_HOST_OUT/nativetest64/par_test/par_test ]; then
- echo "Run 'm par_test' first"
+if [[ ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test/par_test ) || ( ! -f $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3 ) ]]; then
+ echo "Run 'm par_test par_test3' first"
exit 1
fi
@@ -36,4 +36,8 @@ PYTHONHOME= PYTHONPATH= $ANDROID_HOST_OUT/nativetest64/par_test/par_test
PYTHONHOME=/usr $ANDROID_HOST_OUT/nativetest64/par_test/par_test
PYTHONPATH=/usr $ANDROID_HOST_OUT/nativetest64/par_test/par_test
+PYTHONHOME= PYTHONPATH= $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
+PYTHONHOME=/usr $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
+PYTHONPATH=/usr $ANDROID_HOST_OUT/nativetest64/par_test3/par_test3
+
echo "Passed!"
diff --git a/python/tests/testpkg/par_test.py b/python/tests/testpkg/par_test.py
index 22dd09564..ffad430e4 100644
--- a/python/tests/testpkg/par_test.py
+++ b/python/tests/testpkg/par_test.py
@@ -29,7 +29,13 @@ archive = sys.modules["__main__"].__loader__.archive
assert_equal("__name__", __name__, "testpkg.par_test")
assert_equal("__file__", __file__, os.path.join(archive, "testpkg/par_test.py"))
-assert_equal("__package__", __package__, "testpkg")
+
+# Python3 is returning None here for me, and I haven't found any problems caused by this.
+if sys.version_info[0] == 2:
+ assert_equal("__package__", __package__, "testpkg")
+else:
+ assert_equal("__package__", __package__, None)
+
assert_equal("__loader__.archive", __loader__.archive, archive)
assert_equal("__loader__.prefix", __loader__.prefix, "testpkg/")