From c9b01f8f0faa1cab9c77fc92ffbbc01588f3e6b3 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 15 Sep 2022 17:03:16 -0700 Subject: Move py-cachetools to src folder When soong packages python files into a zip file, it will take their path relative to the Android.bp file and preserve that relative path in the zip file. Then the root directory of the zip file is added to the PYTHONPATH. Currently, all subdirectories of the top level zip directory are also added to the PYTHONPATH, but we want to remove this. Since cachetools was being added to the zip file under src/cachetools, "import cachetools" works currectly, but won't work after the PYTHONPATH changes (you'd have to say "import src.cachetools"). To fix this, move the Android.bp file for py-cachetools into the src folder, so the relative paths don't contain src/. Soong python modules do have a pkg_path attribute, which essentially adds more folders to the relative path, but we would need an attribute that removes them, which doesn't exist. This could also be done with a filegroup with the "path" attribute, but bp2build doesn't support that, so I opted to go with this option instead. Bug: 245583294 Test: Presubmits Change-Id: I47d3e743d91f8ac4506ce2f7395ed8c5905d988a --- Android.bp | 16 ---------------- src/Android.bp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 src/Android.bp diff --git a/Android.bp b/Android.bp index ce99854..8fd6a83 100644 --- a/Android.bp +++ b/Android.bp @@ -28,19 +28,3 @@ license { "LICENSE", ], } - -python_library { - name: "py-cachetools", - host_supported: true, - srcs: [ - "src/cachetools/*.py", - ], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: true, - }, - }, -} diff --git a/src/Android.bp b/src/Android.bp new file mode 100644 index 0000000..8782f35 --- /dev/null +++ b/src/Android.bp @@ -0,0 +1,33 @@ +// Copyright 2021 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package { + default_applicable_licenses: ["external_python_cachetools_license"], +} + +python_library { + name: "py-cachetools", + host_supported: true, + srcs: [ + "cachetools/*.py", + ], + version: { + py2: { + enabled: true, + }, + py3: { + enabled: true, + }, + }, +} -- cgit v1.2.3