Skip to content

Commit 177dce8

Browse files
authored
Merge branch 'main' into onboard-grpc-google-iam-v1
2 parents 2a49313 + ef2e130 commit 177dce8

File tree

6,208 files changed

+143115
-34930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,208 files changed

+143115
-34930
lines changed

.generator/Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ RUN apt-get update && \
3939
# Install multiple Python versions from source. `make altinstall` is used to
4040
# prevent replacing the system's default python binary.
4141
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10.18` when the linked issue is resolved.
42-
RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.13.7; do \
42+
RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.13.7 3.14.0; do \
4343
wget https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz && \
4444
tar -xvf Python-${PYTHON_VERSION}.tgz && \
4545
cd Python-${PYTHON_VERSION} && \
@@ -53,7 +53,7 @@ RUN for PYTHON_VERSION in 3.9.23 3.10.18 3.13.7; do \
5353
# Install pip for each python version
5454
# TODO(http://github.com/googleapis/gapic-generator-python/issues/2435): Remove `3.10` when the linked issue is resolved.
5555
RUN wget --no-check-certificate -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' && \
56-
for PYTHON_VERSION in 3.9 3.10 3.13; do \
56+
for PYTHON_VERSION in 3.9 3.10 3.13 3.14; do \
5757
python${PYTHON_VERSION} /tmp/get-pip.py; \
5858
done && \
5959
rm /tmp/get-pip.py
@@ -67,8 +67,10 @@ RUN unzip protoc-25.3-linux-x86_64.zip -d protoc
6767

6868
# Download/extract pandoc
6969
# Pandoc is required by gapic-generator-python for parsing documentation
70-
RUN wget https://github.com/jgm/pandoc/releases/download/3.7.0.2/pandoc-3.7.0.2-linux-amd64.tar.gz
71-
RUN tar -xvf pandoc-3.7.0.2-linux-amd64.tar.gz
70+
ENV PANDOC_VERSION=3.8.2
71+
RUN mkdir pandoc-binary
72+
RUN wget https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz
73+
RUN tar -xvf pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz -C pandoc-binary --strip-components=1
7274

7375
# Download synthtool
7476
RUN git clone --depth 1 https://github.com/googleapis/synthtool.git synthtool
@@ -86,9 +88,6 @@ ENV SYNTHTOOL_TEMPLATES="/synthtool/synthtool/gcp/templates"
8688
# These are the non "-dev" versions of the libraries used in the builder.
8789
RUN apt-get update && \
8890
apt-get install -y --no-install-recommends \
89-
# Temporarily include git and ca-certificates to download gapic-generator from Github
90-
ca-certificates \
91-
git \
9291
# This is needed to avoid the following error:
9392
# `ImportError: libsqlite3.so.0: cannot open shared object file: No such file or directory`.
9493
# `libsqlite3-0` is used by the `coverage` PyPI package which is used when testing libraries
@@ -101,7 +100,7 @@ RUN apt-get update && \
101100
COPY --from=builder protoc/bin /usr/local/bin
102101
COPY --from=builder protoc/include /usr/local/include
103102

104-
COPY --from=builder pandoc-3.7.0.2/bin /usr/local/bin
103+
COPY --from=builder pandoc-binary/bin /usr/local/bin
105104
COPY --from=builder synthtool /synthtool
106105

107106
# Copy all Python interpreters, their pip executables, and their standard libraries from the builder.
@@ -115,6 +114,9 @@ COPY --from=builder /usr/local/lib/python3.10 /usr/local/lib/python3.10
115114
COPY --from=builder /usr/local/bin/python3.13 /usr/local/bin/
116115
COPY --from=builder /usr/local/lib/python3.13 /usr/local/lib/python3.13
117116

117+
COPY --from=builder /usr/local/bin/python3.14 /usr/local/bin/
118+
COPY --from=builder /usr/local/lib/python3.14 /usr/local/lib/python3.14
119+
118120
# Set the working directory in the container.
119121
WORKDIR /app
120122

.generator/cli.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,10 @@ def _process_version_file(content, version, version_path) -> str:
10581058
10591059
Returns: A string with the modified content.
10601060
"""
1061-
pattern = r"(__version__\s*=\s*[\"'])([^\"']+)([\"'].*)"
1061+
if version_path.name.endswith("gapic_version.py"):
1062+
pattern = r"(__version__\s*=\s*[\"'])([^\"']+)([\"'].*)"
1063+
else:
1064+
pattern = r"(version\s*=\s*[\"'])([^\"']+)([\"'].*)"
10621065
replacement_string = f"\\g<1>{version}\\g<3>"
10631066
new_content, num_replacements = re.subn(pattern, replacement_string, content)
10641067
if num_replacements == 0:
@@ -1071,8 +1074,9 @@ def _process_version_file(content, version, version_path) -> str:
10711074
def _update_version_for_library(
10721075
repo: str, output: str, path_to_library: str, version: str
10731076
):
1074-
"""Updates the version string in `**/gapic_version.py` and `samples/**/snippet_metadata.json`
1075-
for a given library.
1077+
"""Updates the version string in `**/gapic_version.py`, `setup.py`,
1078+
`pyproject.toml` and `samples/**/snippet_metadata.json` for a
1079+
given library, if applicable.
10761080
10771081
Args:
10781082
repo(str): This directory will contain all directories that make up a
@@ -1088,8 +1092,15 @@ def _update_version_for_library(
10881092
"""
10891093

10901094
# Find and update gapic_version.py files
1091-
gapic_version_files = Path(f"{repo}/{path_to_library}").rglob("**/gapic_version.py")
1092-
for version_file in gapic_version_files:
1095+
version_files = list(Path(f"{repo}/{path_to_library}").rglob("**/gapic_version.py"))
1096+
if len(version_files) == 0:
1097+
# Fallback to `pyproject.toml`` or `setup.py``. Proto-only libraries have
1098+
# version information in `setup.py` or `pyproject.toml` instead of `gapic_version.py`.
1099+
pyproject_toml = Path(f"{repo}/{path_to_library}/pyproject.toml")
1100+
setup_py = Path(f"{repo}/{path_to_library}/setup.py")
1101+
version_files = [pyproject_toml if pyproject_toml.exists() else setup_py]
1102+
1103+
for version_file in version_files:
10931104
updated_content = _process_version_file(
10941105
_read_text_file(version_file), version, version_file
10951106
)

.generator/requirements.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
click
2-
# Temporarily use a patched version of the generator to avoid getting
3-
# new features/fixes for GAPIC libraries for the purposes of onboarding to librarian
4-
gapic-generator @ git+https://github.com/googleapis/[email protected]
2+
gapic-generator>=1.28.1 # Python 3.14 support, gapic-version support
53
nox
64
starlark-pyo3>=2025.1
75
build

.generator/test_cli.py

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def test_update_global_changelog(mocker, mock_release_init_request_file):
965965
handle.write.assert_called_once_with("[google-cloud-language==1.2.3]")
966966

967967

968-
def test_update_version_for_library_success(mocker):
968+
def test_update_version_for_library_success_gapic(mocker):
969969
m = mock_open()
970970

971971
mock_rglob = mocker.patch(
@@ -984,7 +984,67 @@ def test_update_version_for_library_success(mocker):
984984

985985
handle = m()
986986
assert handle.write.call_args_list[0].args[0] == '__version__ = "1.2.3"'
987+
# Get all the arguments passed to the mock's write method
988+
# and join them into a single string.
989+
written_content = "".join(
990+
[call.args[0] for call in handle.write.call_args_list[1:]]
991+
)
992+
# Create the expected output string with the correct formatting.
993+
assert (
994+
written_content
995+
== '{\n "clientLibrary": {\n "version": "1.2.3"\n }\n}\n'
996+
)
997+
998+
999+
def test_update_version_for_library_success_proto_only_setup_py(mocker):
1000+
m = mock_open()
1001+
1002+
mock_rglob = mocker.patch("pathlib.Path.rglob")
1003+
mock_rglob.side_effect = [[], [pathlib.Path("repo/setup.py")]]
1004+
mock_shutil_copy = mocker.patch("shutil.copy")
1005+
mock_content = 'version = "1.2.2"'
1006+
mock_json_metadata = {"clientLibrary": {"version": "0.1.0"}}
1007+
1008+
with unittest.mock.patch("cli.open", m):
1009+
mocker.patch("cli._read_text_file", return_value=mock_content)
1010+
mocker.patch("cli._read_json_file", return_value=mock_json_metadata)
1011+
_update_version_for_library(
1012+
"repo", "output", "packages/google-cloud-language", "1.2.3"
1013+
)
1014+
1015+
handle = m()
1016+
assert handle.write.call_args_list[0].args[0] == 'version = "1.2.3"'
1017+
# Get all the arguments passed to the mock's write method
1018+
# and join them into a single string.
1019+
written_content = "".join(
1020+
[call.args[0] for call in handle.write.call_args_list[1:]]
1021+
)
1022+
# Create the expected output string with the correct formatting.
1023+
assert (
1024+
written_content
1025+
== '{\n "clientLibrary": {\n "version": "1.2.3"\n }\n}\n'
1026+
)
1027+
1028+
1029+
def test_update_version_for_library_success_proto_only_py_project_toml(mocker):
1030+
m = mock_open()
9871031

1032+
mock_path_exists = mocker.patch("pathlib.Path.exists")
1033+
mock_rglob = mocker.patch("pathlib.Path.rglob")
1034+
mock_rglob.side_effect = [[], [pathlib.Path("repo/pyproject.toml")]]
1035+
mock_shutil_copy = mocker.patch("shutil.copy")
1036+
mock_content = 'version = "1.2.2"'
1037+
mock_json_metadata = {"clientLibrary": {"version": "0.1.0"}}
1038+
1039+
with unittest.mock.patch("cli.open", m):
1040+
mocker.patch("cli._read_text_file", return_value=mock_content)
1041+
mocker.patch("cli._read_json_file", return_value=mock_json_metadata)
1042+
_update_version_for_library(
1043+
"repo", "output", "packages/google-cloud-language", "1.2.3"
1044+
)
1045+
1046+
handle = m()
1047+
assert handle.write.call_args_list[0].args[0] == 'version = "1.2.3"'
9881048
# Get all the arguments passed to the mock's write method
9891049
# and join them into a single string.
9901050
written_content = "".join(
@@ -1099,18 +1159,18 @@ def test_update_changelog_for_library_failure(mocker):
10991159

11001160

11011161
def test_process_version_file_success():
1102-
version_file_contents = '__version__ = "1.2.2"'
1162+
version_file_contents = 'version = "1.2.2"'
11031163
new_version = "1.2.3"
11041164
modified_content = _process_version_file(
1105-
version_file_contents, new_version, "file.txt"
1165+
version_file_contents, new_version, Path("file.txt")
11061166
)
1107-
assert modified_content == f'__version__ = "{new_version}"'
1167+
assert modified_content == f'version = "{new_version}"'
11081168

11091169

11101170
def test_process_version_file_failure():
11111171
"""Tests that value error is raised if the version string cannot be found"""
11121172
with pytest.raises(ValueError):
1113-
_process_version_file("", "", "")
1173+
_process_version_file("", "", Path(""))
11141174

11151175

11161176
def test_create_main_version_header():
@@ -1367,6 +1427,7 @@ def test_get_staging_child_directory_gapic_versioned():
13671427
expected = "v1"
13681428
assert _get_staging_child_directory(api_path, False) == expected
13691429

1430+
13701431
def test_get_staging_child_directory_gapic_non_versioned():
13711432
"""
13721433
Tests the behavior for GAPIC clients with no standard 'v' prefix versioning.

.github/.OwlBot.lock.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python-mono-repo:latest
16-
digest: sha256:b2dd6420495aa1a1057a73b80103ed2cabafa0c2c64a8bbf7221a7d6a067178f
16+
digest: sha256:e5234b94d36c6c89c0a809ef7082a9be82ee66ffc3f4cbb9cb3641df563e4163

.github/workflows/configure_release_please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Set up Python 3.11
4949
uses: actions/setup-python@v6
5050
with:
51-
python-version: 3.13
51+
python-version: 3.14
5252
- name: Run configure_release_please.py
5353
run: python3 configure_release_please.py
5454
working-directory: ./scripts/configure_release_please

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup Python
2626
uses: actions/setup-python@v6
2727
with:
28-
python-version: "3.13"
28+
python-version: "3.14"
2929
- name: Install nox
3030
run: |
3131
python -m pip install --upgrade setuptools pip wheel

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- name: Set up Python 3.10
4646
uses: actions/setup-python@v6
4747
with:
48-
python-version: "3.13"
48+
python-version: "3.14"
4949
- name: Install script dependencies
5050
run: pip3 install -r requirements.txt
5151
working-directory: ./scripts

.github/workflows/scripts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup Python
2222
uses: actions/setup-python@v6
2323
with:
24-
python-version: "3.13"
24+
python-version: "3.14"
2525
- name: Install pytest
2626
run: |
2727
python -m pip install pytest

.github/workflows/unittest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-22.04
2020
strategy:
2121
matrix:
22-
python: ['3.7', '3.8', '3.9', '3.10', "3.11", "3.12", "3.13"]
22+
python: ['3.7', '3.8', '3.9', '3.10', "3.11", "3.12", "3.13", "3.14"]
2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v4
@@ -86,8 +86,8 @@ jobs:
8686
runs-on: ubuntu-latest
8787
strategy:
8888
matrix:
89-
python: ["3.13"]
90-
option: ["core_deps_from_source"]
89+
python: ["3.14"]
90+
option: ["core_deps_from_source-3.14"]
9191
steps:
9292
- name: Checkout
9393
uses: actions/checkout@v4

0 commit comments

Comments
 (0)