diff --git a/github/README.md b/github_tools/README.md similarity index 100% rename from github/README.md rename to github_tools/README.md diff --git a/github_tools/__init__.py b/github_tools/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/github/github_helpers.py b/github_tools/github_helpers.py similarity index 100% rename from github/github_helpers.py rename to github_tools/github_helpers.py diff --git a/github/github_helpers_test.py b/github_tools/github_helpers_test.py similarity index 99% rename from github/github_helpers_test.py rename to github_tools/github_helpers_test.py index 890f27534405..8a3c5dda4e03 100644 --- a/github/github_helpers_test.py +++ b/github_tools/github_helpers_test.py @@ -9,7 +9,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception import unittest from unittest import mock -import github_helpers +from github_tools import github_helpers _TEST_QUERY = """ diff --git a/github/pr_comments.py b/github_tools/pr_comments.py similarity index 97% rename from github/pr_comments.py rename to github_tools/pr_comments.py index e3a3bc76e5d3..2363c0ffc532 100755 --- a/github/pr_comments.py +++ b/github_tools/pr_comments.py @@ -11,9 +11,16 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception import argparse import datetime import hashlib +import os +import sys import textwrap -import github_helpers +# To support direct runs, ensure the pythonpath has the repo root. +_PYTHONPATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "..")) +if _PYTHONPATH not in sys.path: + sys.path.insert(0, _PYTHONPATH) + +from github_tools import github_helpers # The main query, into which other queries are composed. _QUERY = """ diff --git a/github/pr_comments_test.py b/github_tools/pr_comments_test.py similarity index 99% rename from github/pr_comments_test.py rename to github_tools/pr_comments_test.py index fa068479bf83..6c90ffa9b09b 100644 --- a/github/pr_comments_test.py +++ b/github_tools/pr_comments_test.py @@ -10,7 +10,7 @@ import os import unittest from unittest import mock -import pr_comments +from github_tools import pr_comments class TestPRComments(unittest.TestCase): diff --git a/github/update_label_access.py b/github_tools/update_label_access.py similarity index 93% rename from github/update_label_access.py rename to github_tools/update_label_access.py index 2abc0899c79d..000a54f1738b 100755 --- a/github/update_label_access.py +++ b/github_tools/update_label_access.py @@ -14,12 +14,19 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception """ import argparse +import os +import sys # https://github.com/PyGithub/PyGithub # GraphQL is preferred, but falling back to pygithub for unsupported mutations. import github -import github_helpers +# To support direct runs, ensure the pythonpath has the repo root. +_PYTHONPATH = os.path.realpath(os.path.join(os.path.dirname(__file__), "..")) +if _PYTHONPATH not in sys.path: + sys.path.insert(0, _PYTHONPATH) + +from github_tools import github_helpers # The organization to mirror members from. _ORG = "carbon-language" diff --git a/github/update_label_access_test.py b/github_tools/update_label_access_test.py similarity index 97% rename from github/update_label_access_test.py rename to github_tools/update_label_access_test.py index 71489f551306..713c90a0f6ca 100644 --- a/github/update_label_access_test.py +++ b/github_tools/update_label_access_test.py @@ -10,8 +10,8 @@ import github import unittest from unittest import mock -import github_helpers -import update_label_access +from github_tools import github_helpers +from github_tools import update_label_access class TestUpdateLabelAccess(unittest.TestCase):