Add python_test_host module.

bug: 31676493
Test: created py_test modules in real folder. and ran 'mma'.
Change-Id: I22aa2fad74b11e4a31ea7a4c4a4f0ea64cd3fc94
diff --git a/python/python.go b/python/python.go
index 1c74c9a..ab80e4d 100644
--- a/python/python.go
+++ b/python/python.go
@@ -110,11 +110,15 @@
 
 	// the soong_zip arguments for zipping current module source/data files.
 	parSpec parSpec
+
+	// the installer might be nil.
+	installer installer
+
+	subAndroidMkOnce map[subAndroidMkProvider]bool
 }
 
 type PythonSubModule interface {
-	GeneratePythonBuildActions(ctx android.ModuleContext)
-	GeneratePythonAndroidMk() (ret android.AndroidMkData, err error)
+	GeneratePythonBuildActions(ctx android.ModuleContext) android.OptionalPath
 }
 
 type PythonDependency interface {
@@ -123,6 +127,14 @@
 	GetParSpec() parSpec
 }
 
+type pythonDecorator struct {
+	baseInstaller *pythonInstaller
+}
+
+type installer interface {
+	install(ctx android.ModuleContext, path android.Path)
+}
+
 func (p *pythonBaseModule) GetSrcsPathMappings() []pathMapping {
 	return p.srcsPathMappings
 }
@@ -246,10 +258,14 @@
 }
 
 func (p *pythonBaseModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	p.subModule.GeneratePythonBuildActions(ctx)
+	installSource := p.subModule.GeneratePythonBuildActions(ctx)
+
+	if p.installer != nil && installSource.Valid() {
+		p.installer.install(ctx, installSource.Path())
+	}
 }
 
-func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) {
+func (p *pythonBaseModule) GeneratePythonBuildActions(ctx android.ModuleContext) android.OptionalPath {
 	// expand python files from "srcs" property.
 	srcs := p.properties.Srcs
 	switch p.properties.ActualVersion {
@@ -277,7 +293,7 @@
 			strings.HasPrefix(pkg_path, "/") {
 			ctx.PropertyErrorf("pkg_path", "%q is not a valid format.",
 				p.properties.Pkg_path)
-			return
+			return android.OptionalPath{}
 		}
 		// pkg_path starts from "runfiles/" implicitly.
 		pkg_path = filepath.Join(runFiles, pkg_path)
@@ -291,6 +307,8 @@
 	p.parSpec = p.dumpFileList(ctx, pkg_path)
 
 	p.uniqWholeRunfilesTree(ctx)
+
+	return android.OptionalPath{}
 }
 
 // generate current module unique pathMappings: <dest: runfiles_path, src: source_path>
@@ -409,7 +427,7 @@
 				}
 				// binary needs the Python runfiles paths from all its
 				// dependencies to fill __init__.py in each runfiles dir.
-				if sub, ok := p.subModule.(*PythonBinary); ok {
+				if sub, ok := p.subModule.(*pythonBinaryBase); ok {
 					sub.depsPyRunfiles = append(sub.depsPyRunfiles, path.dest)
 				}
 			}
@@ -421,7 +439,7 @@
 			}
 			// binary needs the soong_zip arguments from all its
 			// dependencies to generate executable par file.
-			if sub, ok := p.subModule.(*PythonBinary); ok {
+			if sub, ok := p.subModule.(*pythonBinaryBase); ok {
 				sub.depsParSpecs = append(sub.depsParSpecs, dep.GetParSpec())
 			}
 		}
@@ -442,7 +460,3 @@
 
 	return true
 }
-
-func (p *pythonBaseModule) AndroidMk() (ret android.AndroidMkData, err error) {
-	return p.subModule.GeneratePythonAndroidMk()
-}