Skip to content

Commit

Permalink
python: Fix missing GN deps
Browse files Browse the repository at this point in the history
I discovered a few missing Python GN dependencies while working on the
feature to run all python_actions within an isolated virtualenv. CL for
that feature is:
https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/90060

This CL breaks out those new deps into their own change that can be
landed ahead of the gn venv feature release. This may help stop some
flaky build failures due to Python packages not being installed.

Change-Id: I9e22e6e3a7f55c0dde57b54880f9a55ccc048876
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/92142
Reviewed-by: Armando Montanez <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Anthony DiGirolamo <[email protected]>
  • Loading branch information
AnthonyDiGirolamo authored and CQ Bot Account committed Apr 25, 2022
1 parent e8131f4 commit 7d420a1
Show file tree
Hide file tree
Showing 19 changed files with 118 additions and 19 deletions.
15 changes: 6 additions & 9 deletions pw_build_info/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ import("//build_overrides/pigweed.gni")
import("$dir_pw_build/python.gni")

pw_python_package("py") {
generate_setup = {
metadata = {
name = "pw_build_info"
version = "0.0.1"
}
options = {
install_requires = [ "pyelftools" ]
}
}
inputs = [ "print_build_id.cc" ]
setup = [
"pyproject.toml",
"setup.cfg",
"setup.py",
]
sources = [
"pw_build_info/__init__.py",
"pw_build_info/build_id.py",
]
python_deps = [ "$dir_pw_cli/py" ]

# This test will only ever work on Linux as it requires the ability to compile
# AND run an ELF file.
Expand Down
4 changes: 2 additions & 2 deletions pw_build_info/py/build_id_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import tempfile
import unittest
from pathlib import Path
from pw_cli import env

from pw_build_info import build_id

# Since build_id.cc depends on pw_preprocessor, we have to use the in-tree path.
_MODULE_DIR = Path(env.pigweed_environment().PW_ROOT) / 'pw_build_info'
_MODULE_DIR = Path(__file__).parent.parent.resolve()
_MODULE_PY_DIR = Path(__file__).parent.resolve()

_SHA1_BUILD_ID_LENGTH = 20
Expand Down
16 changes: 16 additions & 0 deletions pw_build_info/py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 The Pigweed Authors
#
# 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
#
# https://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.
[build-system]
requires = ['setuptools', 'wheel']
build-backend = 'setuptools.build_meta'
30 changes: 30 additions & 0 deletions pw_build_info/py/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2021 The Pigweed Authors
#
# 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
#
# https://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.
[metadata]
name = pw_build_info
version = 0.0.1
author = Pigweed Authors
author_email = [email protected]
description = Python scripts that support the GN build

[options]
packages = find:
zip_safe = False
install_requires =
pyelftools

[options.package_data]
pw_build_info =
py.typed
print_build_id.cc
18 changes: 18 additions & 0 deletions pw_build_info/py/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2021 The Pigweed Authors
#
# 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
#
# https://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.
"""pw_build_info"""

import setuptools # type: ignore

setuptools.setup() # Package definition in setup.cfg
1 change: 0 additions & 1 deletion pw_console/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pw_python_package("py") {
python_deps = [
"$dir_pw_cli/py",
"$dir_pw_log_tokenized/py",
"$dir_pw_tokenizer/py",
]
inputs = [
"pw_console/templates/keybind_list.jinja",
Expand Down
2 changes: 1 addition & 1 deletion pw_console/py/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install_requires =
prompt_toolkit>=3.0.26
ptpython>=3.0.20
pw_cli
pw_tokenizer
pw_log_tokenized
pygments
pygments-style-dracula
pygments-style-tomorrow
Expand Down
5 changes: 4 additions & 1 deletion pw_doctor/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pw_python_package("py") {
"pw_doctor/__init__.py",
"pw_doctor/doctor.py",
]
python_deps = [ "$dir_pw_cli/py" ]
python_deps = [
"$dir_pw_cli/py",
"$dir_pw_env_setup/py",
]
pylintrc = "$dir_pigweed/.pylintrc"
}
1 change: 1 addition & 0 deletions pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def pip_install(*args):
'--upgrade',
'pip',
'setuptools',
'toml', # Needed for pyproject.toml package installs.
# Include wheel so pip installs can be done without build
# isolation.
'wheel')
Expand Down
8 changes: 7 additions & 1 deletion pw_hdlc/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ pw_python_package("py") {
"encode_test.py",
]
python_deps = [
"$dir_pw_cli/py",
"$dir_pw_console/py",
"$dir_pw_protobuf_compiler/py",
"$dir_pw_rpc/py",
"$dir_pw_tokenizer/py",
]
python_test_deps = [
"$dir_pw_build/py",
"$dir_pw_log:protos.python",
"$dir_pw_tokenizer/py:test_proto.python",
]
python_test_deps = [ "$dir_pw_build/py" ]
pylintrc = "$dir_pigweed/.pylintrc"
}
7 changes: 6 additions & 1 deletion pw_hdlc/rpc_example/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if (dir_pw_third_party_nanopb == "") {

pw_python_script("example_script") {
sources = [ "example_script.py" ]
python_deps = [ "$dir_pw_hdlc/py" ]
python_deps = [
"$dir_pw_build/py",
"$dir_pw_hdlc/py",
"$dir_pw_log:protos.python",
"$dir_pw_tokenizer/py:test_proto.python",
]
pylintrc = "$dir_pigweed/.pylintrc"
}
1 change: 1 addition & 0 deletions pw_presubmit/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pw_python_package("py") {
python_deps = [
"$dir_pw_build:python_lint",
"$dir_pw_cli/py",
"$dir_pw_env_setup/py",
"$dir_pw_package/py",
]
pylintrc = "$dir_pigweed/.pylintrc"
Expand Down
9 changes: 8 additions & 1 deletion pw_rpc/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ pw_python_package("py") {
"$dir_pw_protobuf_compiler/py",
"$dir_pw_status/py",
]
python_test_deps = [ "$dir_pw_build/py" ]
python_test_deps = [
"$dir_pw_build/py",
"$dir_pw_log:protos.python",
"$dir_pw_tokenizer/py:test_proto.python",
]
pylintrc = "$dir_pigweed/.pylintrc"
proto_library = "..:protos"
}
Expand All @@ -81,8 +85,11 @@ pw_python_script("python_client_cpp_server_test") {
sources = [ "tests/python_client_cpp_server_test.py" ]
python_deps = [
":py",
"$dir_pw_build/py",
"$dir_pw_hdlc/py",
"$dir_pw_log:protos.python",
"$dir_pw_status/py",
"$dir_pw_tokenizer/py:test_proto.python",
]
pylintrc = "$dir_pigweed/.pylintrc"

Expand Down
1 change: 1 addition & 0 deletions pw_system/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pw_python_package("py") {
"$dir_pw_cli/py",
"$dir_pw_console/py",
"$dir_pw_hdlc/py",
"$dir_pw_log:protos.python",
"$dir_pw_protobuf_compiler/py",
"$dir_pw_rpc/py",
"$dir_pw_tokenizer/py",
Expand Down
5 changes: 5 additions & 0 deletions pw_tokenizer/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ pw_python_package("py") {
]
proto_library = "..:proto"
pylintrc = "$dir_pigweed/.pylintrc"

python_deps = [
"$dir_pw_cli/py",
"$dir_pw_protobuf_compiler:test_protos.python",
]
}

# This setup.py may be used to install pw_tokenizer without GN. It does not
Expand Down
1 change: 1 addition & 0 deletions pw_trace_tokenized/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pw_python_package("py") {
]
python_deps = [
"$dir_pw_hdlc/py",
"$dir_pw_log:protos.python",
"$dir_pw_tokenizer/py",
"$dir_pw_trace/py",
]
Expand Down
3 changes: 3 additions & 0 deletions pw_transfer/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ pw_python_script("python_cpp_transfer_test") {
sources = [ "tests/python_cpp_transfer_test.py" ]
python_deps = [
":py",
"$dir_pw_build/py",
"$dir_pw_hdlc/py",
"$dir_pw_log:protos.python",
"$dir_pw_rpc/py",
"$dir_pw_status/py",
"$dir_pw_tokenizer/py:test_proto.python",
"..:test_server_proto.python",
]
pylintrc = "$dir_pigweed/.pylintrc"
Expand Down
5 changes: 4 additions & 1 deletion pw_unit_test/test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ template("pw_test") {
deps = [ ":$_test_target_name" ]
inputs = [ pw_unit_test_AUTOMATIC_RUNNER ]
module = "pw_unit_test.test_runner"
python_deps = [ "$dir_pw_unit_test/py" ]
python_deps = [
"$dir_pw_cli/py",
"$dir_pw_unit_test/py",
]
args = [
"--runner",
rebase_path(pw_unit_test_AUTOMATIC_RUNNER, root_build_dir),
Expand Down
5 changes: 4 additions & 1 deletion pw_watch/py/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ pw_python_package("py") {
]
tests = [ "watch_test.py" ]
pylintrc = "$dir_pigweed/.pylintrc"
python_deps = [ "$dir_pw_cli/py" ]
python_deps = [
"$dir_pw_cli/py",
"$dir_pw_console/py",
]
}

0 comments on commit 7d420a1

Please sign in to comment.