From b4593f5133241fb6e2a948372ad9bd4efb84dac3 Mon Sep 17 00:00:00 2001 From: Jon Meow <46229924+jonmeow@users.noreply.github.com> Date: Wed, 7 Apr 2021 09:08:02 -0700 Subject: [PATCH] Add pip_install to the build. (#435) Updates corresponding tool instructions. --- WORKSPACE | 10 +++++++++- docs/project/contribution_tools.md | 27 +++++++++++++-------------- github_tools/BUILD | 7 ++++++- github_tools/requirements.txt | 7 +++++++ 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 github_tools/requirements.txt diff --git a/WORKSPACE b/WORKSPACE index 9e55947fc772..b976dad12821 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -6,13 +6,21 @@ workspace(name = "carbon") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -# Add Bazel's python rules. +# Add Bazel's python rules and set up pip. http_archive( name = "rules_python", sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0", url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz", ) +load("@rules_python//python:pip.bzl", "pip_install") + +# Create a central repo that knows about the pip dependencies. +pip_install( + name = "py_deps", + requirements = "//github_tools:requirements.txt", +) + # Bootstrap a Clang and LLVM toolchain. load("//bazel/cc_toolchains:clang_bootstrap.bzl", "bootstrap_clang_toolchain") diff --git a/docs/project/contribution_tools.md b/docs/project/contribution_tools.md index 52329d9744fa..ec97626cc494 100644 --- a/docs/project/contribution_tools.md +++ b/docs/project/contribution_tools.md @@ -27,8 +27,6 @@ contributions. - [Clang and LLVM](#clang-and-llvm) - [Ninja](#ninja) - [pre-commit](#pre-commit) - - [gql](#gql) - - [PyGitHub](#pygithub) - [Optional tools](#optional-tools) - [Carbon-maintained](#carbon-maintained) - [new_proposal.py](#new_proposalpy) @@ -229,18 +227,6 @@ git commit When modifying or adding pre-commit hooks, please run `pre-commit run --all-files` to see what changes. -### gql - -```bash -pip install gql -``` - -### PyGitHub - -```bash -pip install PyGitHub -``` - ## Optional tools ### Carbon-maintained @@ -268,6 +254,19 @@ Options can be seen with `-h`. A couple key options to be aware of are: - `--comments-from LOGIN`: Only print threads with comments from the given user. For example, use when looking for threads that you've commented on. +This script may be run directly if `gql` is installed: + +```bash +pip install gql +./github_tools/pr_comments.py +``` + +It may also be run using `bazel`, without installing `gql`: + +```bash +bazel run //github_tools:pr_comments -- +``` + ### GitHub #### gh CLI diff --git a/github_tools/BUILD b/github_tools/BUILD index 23ebb793fa90..f9918c41aff3 100644 --- a/github_tools/BUILD +++ b/github_tools/BUILD @@ -3,10 +3,12 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") +load("@py_deps//:requirements.bzl", "requirement") py_library( name = "github_helpers", srcs = ["github_helpers.py"], + deps = [requirement("gql")], ) py_test( @@ -34,7 +36,10 @@ py_binary( name = "update_label_access", srcs = ["update_label_access.py"], python_version = "PY3", - deps = ["github_helpers"], + deps = [ + "github_helpers", + requirement("pygithub"), + ], ) py_test( diff --git a/github_tools/requirements.txt b/github_tools/requirements.txt new file mode 100644 index 000000000000..e3f75f64a73a --- /dev/null +++ b/github_tools/requirements.txt @@ -0,0 +1,7 @@ +# Part of the Carbon Language project, under the Apache License v2.0 with LLVM +# Exceptions. See /LICENSE for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +# Python dependencies, consumed by /WORKSPACE. +gql +PyGitHub