Просмотр исходного кода

Add pip_install to the build. (#435)

Updates corresponding tool instructions.
Jon Meow 5 лет назад
Родитель
Сommit
b4593f5133
4 измененных файлов с 35 добавлено и 16 удалено
  1. 9 1
      WORKSPACE
  2. 13 14
      docs/project/contribution_tools.md
  3. 6 1
      github_tools/BUILD
  4. 7 0
      github_tools/requirements.txt

+ 9 - 1
WORKSPACE

@@ -6,13 +6,21 @@ workspace(name = "carbon")
 
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 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(
 http_archive(
     name = "rules_python",
     name = "rules_python",
     sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
     sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
     url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
     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.
 # Bootstrap a Clang and LLVM toolchain.
 load("//bazel/cc_toolchains:clang_bootstrap.bzl", "bootstrap_clang_toolchain")
 load("//bazel/cc_toolchains:clang_bootstrap.bzl", "bootstrap_clang_toolchain")
 
 

+ 13 - 14
docs/project/contribution_tools.md

@@ -27,8 +27,6 @@ contributions.
     -   [Clang and LLVM](#clang-and-llvm)
     -   [Clang and LLVM](#clang-and-llvm)
     -   [Ninja](#ninja)
     -   [Ninja](#ninja)
     -   [pre-commit](#pre-commit)
     -   [pre-commit](#pre-commit)
-    -   [gql](#gql)
-    -   [PyGitHub](#pygithub)
 -   [Optional tools](#optional-tools)
 -   [Optional tools](#optional-tools)
     -   [Carbon-maintained](#carbon-maintained)
     -   [Carbon-maintained](#carbon-maintained)
         -   [new_proposal.py](#new_proposalpy)
         -   [new_proposal.py](#new_proposalpy)
@@ -229,18 +227,6 @@ git commit
 When modifying or adding pre-commit hooks, please run
 When modifying or adding pre-commit hooks, please run
 `pre-commit run --all-files` to see what changes.
 `pre-commit run --all-files` to see what changes.
 
 
-### gql
-
-```bash
-pip install gql
-```
-
-### PyGitHub
-
-```bash
-pip install PyGitHub
-```
-
 ## Optional tools
 ## Optional tools
 
 
 ### Carbon-maintained
 ### 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
 -   `--comments-from LOGIN`: Only print threads with comments from the given
     user. For example, use when looking for threads that you've commented on.
     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 <PR#>
+```
+
+It may also be run using `bazel`, without installing `gql`:
+
+```bash
+bazel run //github_tools:pr_comments -- <PR#>
+```
+
 ### GitHub
 ### GitHub
 
 
 #### gh CLI
 #### gh CLI

+ 6 - 1
github_tools/BUILD

@@ -3,10 +3,12 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
 
 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
 load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
+load("@py_deps//:requirements.bzl", "requirement")
 
 
 py_library(
 py_library(
     name = "github_helpers",
     name = "github_helpers",
     srcs = ["github_helpers.py"],
     srcs = ["github_helpers.py"],
+    deps = [requirement("gql")],
 )
 )
 
 
 py_test(
 py_test(
@@ -34,7 +36,10 @@ py_binary(
     name = "update_label_access",
     name = "update_label_access",
     srcs = ["update_label_access.py"],
     srcs = ["update_label_access.py"],
     python_version = "PY3",
     python_version = "PY3",
-    deps = ["github_helpers"],
+    deps = [
+        "github_helpers",
+        requirement("pygithub"),
+    ],
 )
 )
 
 
 py_test(
 py_test(

+ 7 - 0
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