summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)Author
2023-01-03Allow adding extra tradefed options in the Android.bp file Cole Faust
Some tests need to add custom tradefed options, but still want to keep most of the soong autogenerated tradefed xml file. Expose a test_options: { tradefed_options: [...] } property that will allow tests to add more options to the autogenerated xml file. Fixes: 184895128 Test: go test, and verified that the ninja files did not change for aosp_arm64 Change-Id: I50d4ad139322e9e207202f1e1a50f5bbb424aa6f
2022-12-19Revert "Allow adding extra tradefed options in the Android.bp file" Tahsin Loqman
This reverts commit 8ec823cba166a41eb0e9e5ff8fe679e691fec678. Reason for revert: DroidMonitor: Potential culprit for Bug b/262965953 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: I236cc36981d8b30527ca286632727f8ca267e969
2022-12-09Allow adding extra tradefed options in the Android.bp file Cole Faust
Some tests need to add custom tradefed options, but still want to keep most of the soong autogenerated tradefed xml file. Expose a test_options: { tradefed_options: [...] } property that will allow tests to add more options to the autogenerated xml file. Fixes: 184895128 Test: go test, and verified that the ninja files did not change for aosp_arm64 Change-Id: I75f7eb002c8325ce7cdc76e12e76e16195320620
2022-10-21Remove flags that enable the new python path behavior Cole Faust
The new behavior has been enabled by default, and these flags aren't necessary anymore. Fixes: 245583294 Test: m py_dont_import_folder_of_entrypoint_test && /ssd/aosp-master/out/host/linux-x86/testcases/py_dont_import_folder_of_entrypoint_test/x86_64/py_dont_import_folder_of_entrypoint_test Change-Id: I5b6f98da51791bc5d28662ef799a10c1bb6a35a0
2022-10-13Merge "Fix some issues in bp2build converter for python_binary_host." Wei Li
2022-10-12Fix some issues in bp2build converter for python_binary_host. Wei Li
1) Bp2build convert python_binary_host main attribute as LabelAttribute. Currently "main" attribute in python_binary_host is handled as string but for some modules (e.g certify_bootimg) the "main" attribute points to a file in its subpackage like "subpackage/file.py" and should be converted to "//.../subpackage:file.py". 2) Filter out duplicated labels in the merged list of "required" attributes of python_binary_host and its defaults. Test: b build //system/tools/mkbootimg:certify_bootimg Test: b build //build/make/tools/releasetools:check_target_files_signatures Bug: 253081249 Bug: 253101186 Change-Id: Ic2cb4cadec2c1348da70af9f0730da9914d3a8ca
2022-10-11Merge "Revert^2 "Enable new python path behavior by default"" Cole Faust
2022-10-11Revert^2 "Enable new python path behavior by default" Cole Faust
This reverts commit 4d5cc709fa16f5dc78f690369e946fcf66156312. Reason for revert: Acloud issue was fixed in aosp/2243150, make sure the host unit tests are run on this cl via go/abtd before submitting Change-Id: Ie148430d331a01a9877adaf3cb88f1c57af136a0 Bug: 245583294 Bug: 247578564 Bug: 251688241
2022-10-07Merge "Revert "Enable new python path behavior by default"" Lais Andrade
2022-10-07Revert "Enable new python path behavior by default" Lais Andrade
This reverts commit 5fe655d1c71ee079dd46e93c96b54aae39a10d16. Reason for revert: DroidMonitor: Potential culprit for Bug b/251688241 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: I1ea4df27557fc891d8f0156ec5681f9b0c601c98
2022-10-07Merge "Enable new python path behavior by default" Treehugger Robot
2022-10-05Enable new python path behavior by default Cole Faust
Now that usages have been updated, enable the new behavior by default. If everything goes well with this, we can then remove the flags. Bug: 245583294 Bug: 247578564 Test: Presubmits Change-Id: Idac8d2dc0f96ae750dba4a99b32525676d0d6f25
2022-09-29[LSC] Add LOCAL_LICENSE_KINDS to build/soong Bob Badour
Added SPDX-license-identifier-Apache-2.0 to: python/tests/dont_import_folder_of_entrypoint/Android.bp python/tests/top_level_dirs/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Change-Id: I7a1ea160c685361318f9a8543e10b83eeb9dcb7f
2022-09-26Add binary properties to python_defaults and add modern_python_path_defaults Cole Faust
So that we can more easily enable these new flags on several modules. It seems you can still apply a python_defaults to a python_library even with this change, so I didn't break it out into a separate python_binary_defaults. Bug: 245583294 Test: m py_dont_import_folder_of_entrypoint_test && out/host/linux-x86/testcases/py_dont_import_folder_of_entrypoint_test/x86_64/py_dont_import_folder_of_entrypoint_test Change-Id: Iecf9c1845df4630bafdea9957eb2450c15f8596b
2022-09-26Add flag to not add directory of entrypoint to sys.path Cole Faust
The python interpreter will by default add the directory of the entrypoint script to the beginning of sys.path. This can be disabled in python 3.11+ (which is not released yet) using the PYTHON_SAFE_PATH environment variable or the -P flag. As a workaround to have this behavior in older python versions, we can make an __soong_entrypoint_redirector__.py file at the root of the zip file that is the entrypoint, and then that file will redirect to the real entrypoint. This brings non-embedded-launcher python modules closer to the embedded launcher version. The embedded launcher binaries already act like this because they start at an __main__.py file at the root of the zip file. Bug: 245583294 Test: m py_dont_import_folder_of_entrypoint_test && out/host/linux-x86/nativetest64/py_dont_import_folder_of_entrypoint_test/py_dont_import_folder_of_entrypoint_test Change-Id: I39aaf04fb19c3ba7f5c9d98220872d6d08abf736
2022-09-26Merge "Add flag to not add top-level modules to PYTHONPATH" Cole Faust
2022-09-23Add flag to not add top-level modules to PYTHONPATH Cole Faust
stub_template_host.txt added all the top-level modules to the PYTHONPATH, which isn't correct, and caused absl.logging to override the built-in logging module. Removing this also makes it more consistent with python binaries built with embedded_launcher: true. embedded_launcher: true binaries don't add the top-level modules. Fixes: 245583294 Test: m py_dont_add_top_level_dirs_test && out/host/linux-x86/testcases/py_dont_add_top_level_dirs_test/x86_64/py_dont_add_top_level_dirs_test Change-Id: Id3069565d2b2c4b2bda0ff5301e757a7b4201751
2022-09-22[LSC] Add LOCAL_LICENSE_KINDS to build/soong Bob Badour
Added SPDX-license-identifier-Apache-2.0 to: python/tests/proto_pkg_path/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Change-Id: I17e9945a265d0ede3e291ed6f5d410dde035fbe5
2022-09-20Make protobufs respect pkg_path properly Cole Faust
Currently, python protobuf sources are generated as if pkg_path didn't exist, but then are moved into the pkg_path directory after being generated. This means they're generated with import statements in them that don't include the pkg_path. These import statements won't work at all when pkg_path is at least 2 levels deep, but currently erroneously work with a 1 level deep pkg_path because we mistakenly add the top-level modules in a soong-built python zip to the PYTHONPATH. We want to remove those modules from the PYTHONPATH, so the generated protobuf source files have to use the correct imports. Since there are existing cases of code that needs to be updated, guard this new behavior behind a flag, protos_respect_pkg_path. We will set this to true on modules individually as we update them, and then eventually change the default to true and remove this flag. Bug: 247578564 Test: m py_proto_pkg_path_test && out/host/linux-x86/nativetest64/py_proto_pkg_path_test/py_proto_pkg_path_test Change-Id: I3695cf5521837da087592f2ad5350201035b7b0e
2022-09-09Don't close file descriptors when starting python program Cole Faust
Python programs run via a wrapper script. That wrapper script can be started with open file descriptors, for example by using the <(echo foo) syntax in bash. The shouldn't be closed when starting the real script. Bug: 203436762 Test: Presubmits Change-Id: Ib20450f713b15c8a5527d1e433bfd9635cead85f
2022-08-17Reformat build/soong for go 1.19 Colin Cross
Test: none Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17Move common test_options properties into the android package Zhenhuang Wang
Multiple modules (e.g. java, cc, python, rust) define the `test_options` field. Extract the common properties in test_options to share across different test rules. Bug: 240928948 Test: `refreshmod` and diff with original module-info.json Change-Id: I404a7a157b4ccaa53d800ee2217559ff695bd825
2022-06-09Allowlist apexer for bp2build Cole Faust
This also introduces a workaround for the fact that apexer depends on aapt2, but aapt2 doesn't build with bp2build yet. Aapt2 is removed from apexer's requirements during bp2build. Bug: 204244290 Test: ./build/bazel/ci/bp2build.sh Change-Id: I837597ce035c7d5c06e1a3957166583a7a94b5c7
2022-05-26Add bp2build converter for python protobuf files Cole Faust
Bug: 196084681 Test: b run //build/bazel/examples/python/protobuf:build_bazel_examples_python_protobuf_main --config=linux_x86_64 Change-Id: I4d806902d262351231f64686a5d24513a25d9749
2022-05-19Add imports property to py_library rules Cole Faust
This is to avoid having it hardcoded in a fork of the py_library rule. Most import attributes should just be set to ".", but our previous solution always hardcoded it to ".." instead, for ndkstubgen. ndkstubgen uses pkg_path: "ndkstubgen", i.e., it set pkg_path to the name of the folder that contained the Android.bp file. In this specific scenario, imports = ".." works. Recreate that behavior here as well, because we don't handle pkg_path properly yet. Fixes: 233081071 Test: build/bazel/ci/bp2build.sh Change-Id: Ib5e6a8edf428c74d4b5947f0ec53a2151001367a
2022-03-08Support building python pars against static or shared musl libc Colin Cross
Support building python pars against musl libc by either adding libc_musl as an install dependency or using the static version of the python launchers. Bug: 179809553 Test: m USE_HOST_MUSL=true apexer deapexer Test: m USE_HOST_MUSL=true BUILD_HOST_static=true apexer deapexer Change-Id: I4a56efb227bea746836eb785d929eb4b5d8e15f1
2021-12-15Remove InstallBypassMake and ToMakePath Colin Cross
InstallBypassMake and ToMakePath are obsolete, remove them. Bug: 204136549 Test: m checkbuild Change-Id: Ie5a6f7254b3d317ed6039e114ed6aec35e1ce273
2021-12-14Use one mutator for all bp2build conversion. Liz Kammer
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
2021-12-03Allowlist //build/soong/cc/{ndkstubgen,symbolfile}. Jingwen Chen
This contains the tool to generate stub libraries. Bug: 208215661 Bug: 207812332 Test: b run //build/soong/cc/ndkstubgen Change-Id: Id48d74381457e0a62aca0ed7f8a9367886863bfd
2021-12-01Support empty strings in bp2build Liz Kammer
Previously, could not set an empty string as a value of an attribute; however, this is necessary in some cases. To not unnecessarily create an empty string, use string pointers for attributes rather than strings. Test: go test bp2build tests Change-Id: I03b3a3567452d455246d22d81f86c317d06b7c39
2021-11-22Switch default for InstallBypassMake to true Colin Cross
Enable InstallBypassMake for all module types by switching its default to true. Bug: 204136549 Test: m checkbuild Change-Id: Ied082995e74d71dee6aecea99689ac3f63600d3b
2021-11-03Revert "Fix python_binary_host module in mixed build." Rupert Shuttleworth
Revert submission 1861755-fix_python_binary_host_in_mixed_build Reason for revert: Broke Bazel CI, please see https://android-build.googleplex.com/builds/submitted/7879108/mixed_droid-clean/latest/view/logs/build_error.log and https://android-build.googleplex.com/builds/submitted/7879108/mixed_droid-incremental/latest/view/logs/build_error.log Reverted Changes: Ica457ee71:Add platform needed by python_binary_host. Ibc8b99a92:Fix python_binary_host module in mixed build. Change-Id: I3d6c4f6edee2d00bdc78efd5cee64f4c915baeaa
2021-11-02Fix python_binary_host module in mixed build. Wei Li
Test: USE_BAZEL_ANALYSIS=1 m genfunctosyscallnrs Test: USE_BAZEL_ANALYSIS=1 m func_to_syscall_nrs Test: USE_BAZEL_ANALYSIS=1 m libseccomp_policy Bug: 201094425, 197135289 Change-Id: Ibc8b99a92149410c8a879b7a4facf6c8961a7b9f
2021-10-04Bp2Build common properties auto-handling Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Introduce `commonAttributes` & `fillCommonBp2BuildModuleAttrs used in CreateBazelTargetModule Adapt `bp2BuildInfo` to use `commonAttrs` instead of `Name`. And thus also all downstream users of `CreateBazelTargetModule`. As initial user, the Soong `required` property will be translated to Bazel's `data`. Bug: 198146582, 196091467 Test: build_converstion_test.go:TestCommonBp2BuildModuleAttrs Test: go test Test: mixed_{libc,droid}.sh Change-Id: Ib500e40f7e2cb48c459f1ebe3188962fc41ec124
2021-10-01Have python_*{,_host} handle arch-variants Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Bug: 196081778 Test: TestPython*{,Host}ArchVariance Test: go test Test: mixed_{libc,droid}.sh Change-Id: I89304e58f5bacd61534732bade4ad6bb5f2671c0
2021-09-20Remove arch-variant from some python properties Liz Kammer
Version and package should not vary based on architecture. Test: m nothing Change-Id: Id9cb655d9c25caee3b6068a261b3db36e1654467
2021-09-14Merge "Add module based host-tools snapshot" Rob Seymour
2021-09-13Add module based host-tools snapshot Rob Seymour
Add new module: host_snapshot { name: "host-snapshot" deps: [ (list of host tools) ], ... } Package host tools using android.PackagingBase to capture host tools and transitive packaging data. Add JSON meta data to snapshot that allows snapshot to be installed via development/vendor_snapshot/update.py Add support to generate a fake host snapshot of all host modules that is used to detect required modules via development/vendor_snapshot/update.py. Bug: 192556798 Bug: 194799048 Bug: 192896149 Test: m HOST_FAKE_SNAPSHOT_ENABLE=true host-fake-snapshot dist -- check snapshot exists in dist Change-Id: I849c4db801cd858408f6fe6a3ce69262a23a5be9
2021-08-27python_{binary,library}{,_host} handle lib property Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Have binary and library bp2build convert `libs` to `deps` for bazel Bug: 196083751 Test: python_{binary,library}_conversion_test.go Test: build/bazel/ci/mixed_{libc,droid}.sh Change-Id: I2d5f6ef2e83dd608910edb7adb2eb9a56d25293c
2021-08-26Add python_library_host -> py_library bp2build support Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Bug: 196081770 Test: bp2build/python_library_conversion_test.go Test: build/bazel/ci/mixed_{libc,droid}.sh Change-Id: I4da9938eb0b039f97b83badd2269af153c7edbcc
2021-08-25Add python_library -> py_library bp2build support Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
Bug: 196091681 Test: bp2build/python_library_conversion_test.go Test: build/bazel/ci/mixed_{libc,droid}.sh Change-Id: Ice87d75533c97fd9c139dc59de09a039e2713a01
2021-08-20Fix inverted error message Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
The code checks to see if the `child` is not a Python library, but then when reporting the error it uses the module name as the dependency name and the child (dependency) as the module name Test: Existing tests pass Change-Id: Ied606342291312d8485a8fd2ddcc580ad24ae82f
2021-08-17Don't create a new module for bp2build conversion. Liz Kammer
A performance improvement for bp2build as Blueprint/Soong no longer have the overhead of additional modules. The creation of these modules results in: * traversal of additional modules for each subsequent mutator * synchronization over a go channel to collect newly created modules: https://cs.android.com/android/platform/superproject/+/master:build/blueprint/context.go;l=2594,2600;drc=1602226f23181b8c3fbfcaf3358f0297e839d7d3 We avoid both of these by storing the information directly in the underlying module. Also as a fringe benefit, removes some necessary boilerplate for conversion. For benchmarks, reduces runtime ~1% for 1% converted, ~24% for 100% converted. See more: go/benchmarks-for-https:-r.android.com-1792714 Test: ran benchmarks/tests in bp2build Test: build/bazel/ci/bp2build.sh Change-Id: Ie9273b8cbab5bc6edac1728067ce184382feb211
2021-05-27Merge "Switch python_test_host default to unit_test:true" Julien Desprez
2021-05-27Switch python_test_host default to unit_test:true Julien Desprez
Test: presubmit Bug: 183730987 Change-Id: Ib54c30c751731aaae8a46af96e809c46469659d1
2021-05-03Support blueprint_go_binary in PathForModuleSrc Colin Cross
Allow blueprint_go_binary to be used as test data by supporting it in PathForModuleSrc. Also make python use GetDirectDepsWithTag instead of VisitDirectDeps so it doesn't fail on the dependency to a Blueprint (non-Android) module. Fixes: 186528269 Test: manual Change-Id: Ibc1d7caf7bf1fa5db805c3b885a95df4baee0ecf
2021-04-20Mark par_test as not unit tests Julien Desprez
They seem to be used as Soong validation. They are not implemented against the python unit tests framework, so we can execute them as such in CI automatically. Change-Id: I8fe662d5d3399d60c8a05acc79b4dd51b5d138a6 Test: presubmit Bug: 183730987
2021-04-19Change par file generate rules. yangbill
Make sure the shebang of the par file is consistent with the main python script rather than use /usr/bin/python arbitrarily. Bug: 185399398 Bug: 185094069 Test: m atest ; atest-dev --help m atest-py2 ; atest-py2-dev --help Change-Id: Ice4590b3d173e6d11e608c2ca29b297df0dc4089
2021-03-30bp2build: arch-configurable selects for label list attrs. Jingwen Chen
This CL adds the configurable LabelListAttribute support to bp2build. Test: go test Change-Id: I2ef9e385d9cf1b1845988128eca1d8cda1ecb5e8
2021-03-24bp2build: add allowlist for package-level conversions. Jingwen Chen
This CL adds the support for specifying lists of directories in build/soong/android/bazel.go, which are then written into out/soong/bp2build/MANIFEST. Using this configuration, modules/directories can either default to bp2build_available: true or false, while still retaining the ability to opt-in or out at the module level. It also ensures that ConvertWithBp2Build returns true iff the module type has a registered bp2build converter. Test: go tests Test: demo.sh full Test: TreeHugger presubmits for bp2build and mixed builds. Change-Id: I0e0f6f4b1b2ec045f2f1c338f7084defc5d23a55