diff --git a/.github/release-please.yml b/.github/release-please.yml index 6def37a..e9a4f00 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,5 +1,6 @@ releaseType: python handleGHRelease: true +manifest: true # NOTE: this section is generated by synthtool.languages.python # See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py branches: diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..0c7bbf6 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.2.8" +} diff --git a/.repo-metadata.json b/.repo-metadata.json index a4ab9b1..faa55b5 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -6,7 +6,7 @@ "issue_tracker": "http://github.com/googleapis/python-source-context/issues", "release_level": "stable", "language": "python", - "library_type": "GAPIC_AUTO", + "library_type": "OTHER", "repo": "googleapis/python-source-context", "distribution_name": "google-cloud-source-context", "api_id": "source.googleapis.com", diff --git a/docs/source_context_v1/types.rst b/docs/source_context_v1/types.rst index 7429050..a67b387 100644 --- a/docs/source_context_v1/types.rst +++ b/docs/source_context_v1/types.rst @@ -3,5 +3,4 @@ Types for Google Cloud Source Context v1 API .. automodule:: google.cloud.source_context_v1.types :members: - :undoc-members: :show-inheritance: diff --git a/google/cloud/source_context/__init__.py b/google/cloud/source_context/__init__.py index aa00e35..62a234d 100644 --- a/google/cloud/source_context/__init__.py +++ b/google/cloud/source_context/__init__.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.source_context import gapic_version as package_version + +__version__ = package_version.__version__ from google.cloud.source_context_v1.types.source_context import ( diff --git a/google/cloud/source_context/gapic_version.py b/google/cloud/source_context/gapic_version.py new file mode 100644 index 0000000..70525fe --- /dev/null +++ b/google/cloud/source_context/gapic_version.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2022 Google LLC +# +# 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 +# +# http://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. +# +__version__ = "1.2.8" # {x-release-please-version} diff --git a/google/cloud/source_context_v1/__init__.py b/google/cloud/source_context_v1/__init__.py index 1deb918..8a5f0d4 100644 --- a/google/cloud/source_context_v1/__init__.py +++ b/google/cloud/source_context_v1/__init__.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.cloud.source_context import gapic_version as package_version + +__version__ = package_version.__version__ from .types.source_context import ( diff --git a/google/cloud/source_context_v1/types/source_context.py b/google/cloud/source_context_v1/types/source_context.py index 495b559..c54960b 100644 --- a/google/cloud/source_context_v1/types/source_context.py +++ b/google/cloud/source_context_v1/types/source_context.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from typing import MutableMapping, MutableSequence + import proto # type: ignore __protobuf__ = proto.module( @@ -67,25 +69,25 @@ class SourceContext(proto.Message): This field is a member of `oneof`_ ``context``. """ - cloud_repo = proto.Field( + cloud_repo: "CloudRepoSourceContext" = proto.Field( proto.MESSAGE, number=1, oneof="context", message="CloudRepoSourceContext", ) - cloud_workspace = proto.Field( + cloud_workspace: "CloudWorkspaceSourceContext" = proto.Field( proto.MESSAGE, number=2, oneof="context", message="CloudWorkspaceSourceContext", ) - gerrit = proto.Field( + gerrit: "GerritSourceContext" = proto.Field( proto.MESSAGE, number=3, oneof="context", message="GerritSourceContext", ) - git = proto.Field( + git: "GitSourceContext" = proto.Field( proto.MESSAGE, number=6, oneof="context", @@ -100,16 +102,16 @@ class ExtendedSourceContext(proto.Message): Attributes: context (google.cloud.source_context_v1.types.SourceContext): Any source context. - labels (Mapping[str, str]): + labels (MutableMapping[str, str]): Labels with user defined metadata. """ - context = proto.Field( + context: "SourceContext" = proto.Field( proto.MESSAGE, number=1, message="SourceContext", ) - labels = proto.MapField( + labels: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, number=2, @@ -133,12 +135,12 @@ class Kind(proto.Enum): MOVABLE = 2 OTHER = 4 - kind = proto.Field( + kind: Kind = proto.Field( proto.ENUM, number=1, enum=Kind, ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=2, ) @@ -172,22 +174,22 @@ class CloudRepoSourceContext(proto.Message): This field is a member of `oneof`_ ``revision``. """ - repo_id = proto.Field( + repo_id: "RepoId" = proto.Field( proto.MESSAGE, number=1, message="RepoId", ) - revision_id = proto.Field( + revision_id: str = proto.Field( proto.STRING, number=2, oneof="revision", ) - alias_name = proto.Field( + alias_name: str = proto.Field( proto.STRING, number=3, oneof="revision", ) - alias_context = proto.Field( + alias_context: "AliasContext" = proto.Field( proto.MESSAGE, number=4, oneof="revision", @@ -207,12 +209,12 @@ class CloudWorkspaceSourceContext(proto.Message): most recent snapshot. """ - workspace_id = proto.Field( + workspace_id: "CloudWorkspaceId" = proto.Field( proto.MESSAGE, number=1, message="CloudWorkspaceId", ) - snapshot_id = proto.Field( + snapshot_id: str = proto.Field( proto.STRING, number=2, ) @@ -250,25 +252,25 @@ class GerritSourceContext(proto.Message): This field is a member of `oneof`_ ``revision``. """ - host_uri = proto.Field( + host_uri: str = proto.Field( proto.STRING, number=1, ) - gerrit_project = proto.Field( + gerrit_project: str = proto.Field( proto.STRING, number=2, ) - revision_id = proto.Field( + revision_id: str = proto.Field( proto.STRING, number=3, oneof="revision", ) - alias_name = proto.Field( + alias_name: str = proto.Field( proto.STRING, number=4, oneof="revision", ) - alias_context = proto.Field( + alias_context: "AliasContext" = proto.Field( proto.MESSAGE, number=5, oneof="revision", @@ -288,11 +290,11 @@ class GitSourceContext(proto.Message): required. """ - url = proto.Field( + url: str = proto.Field( proto.STRING, number=1, ) - revision_id = proto.Field( + revision_id: str = proto.Field( proto.STRING, number=2, ) @@ -321,13 +323,13 @@ class RepoId(proto.Message): This field is a member of `oneof`_ ``id``. """ - project_repo_id = proto.Field( + project_repo_id: "ProjectRepoId" = proto.Field( proto.MESSAGE, number=1, oneof="id", message="ProjectRepoId", ) - uid = proto.Field( + uid: str = proto.Field( proto.STRING, number=2, oneof="id", @@ -346,11 +348,11 @@ class ProjectRepoId(proto.Message): default repo. """ - project_id = proto.Field( + project_id: str = proto.Field( proto.STRING, number=1, ) - repo_name = proto.Field( + repo_name: str = proto.Field( proto.STRING, number=2, ) @@ -370,12 +372,12 @@ class CloudWorkspaceId(proto.Message): the Source API's CreateWorkspace method. """ - repo_id = proto.Field( + repo_id: "RepoId" = proto.Field( proto.MESSAGE, number=1, message="RepoId", ) - name = proto.Field( + name: str = proto.Field( proto.STRING, number=2, ) diff --git a/owlbot.py b/owlbot.py new file mode 100644 index 0000000..ce738f0 --- /dev/null +++ b/owlbot.py @@ -0,0 +1,56 @@ +# Copyright 2022 Google LLC +# +# 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 +# +# http://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. + +import json +from pathlib import Path +import shutil + +import synthtool as s +import synthtool.gcp as gcp +from synthtool.languages import python + +# ---------------------------------------------------------------------------- +# Copy the generated client from the owl-bot staging directory +# ---------------------------------------------------------------------------- + +clean_up_generated_samples = True + +# Load the default version defined in .repo-metadata.json. +default_version = json.load(open(".repo-metadata.json", "rt")).get( + "default_version" +) + +for library in s.get_staging_dirs(default_version): + if clean_up_generated_samples: + shutil.rmtree("samples/generated_samples", ignore_errors=True) + clean_up_generated_samples = False + s.move([library], excludes=["**/gapic_version.py"]) +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- + +templated_files = gcp.CommonTemplates().py_library( + cov_level=100, + microgenerator=True, + versions=gcp.common.detect_versions(path="./google", default_first=True), +) +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"]) + +python.py_samples(skip_readmes=True) + +# run format session for all directories which have a noxfile +for noxfile in Path(".").glob("**/noxfile.py"): + s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False) diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..cf8d9c5 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "python", + "extra-files": [ + "google/cloud/source_context/gapic_version.py" + ] + } + }, + "release-type": "python", + "plugins": [ + { + "type": "sentence-case" + } + ], + "initial-version": "0.1.0" + } + \ No newline at end of file diff --git a/setup.py b/setup.py index 0fbe015..49a7a96 100644 --- a/setup.py +++ b/setup.py @@ -1,37 +1,48 @@ # -*- coding: utf-8 -*- -# -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # 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 +# http://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. - +# import io import os -import setuptools +import setuptools # type: ignore + +package_root = os.path.abspath(os.path.dirname(__file__)) name = "google-cloud-source-context" -description = "Python client for Source Context" -version = "1.2.8" -release_status = "Development Status :: 5 - Production/Stable" -url = "https://github.com/googleapis/python-source-context" + + +description = "Google Cloud Source Context API client library" + +version = {} +with open( + os.path.join(package_root, "google/cloud/source_context/gapic_version.py") +) as fp: + exec(fp.read(), version) +version = version["__version__"] + +if version[0] == "0": + release_status = "Development Status :: 4 - Beta" +else: + release_status = "Development Status :: 5 - Production/Stable" + dependencies = [ - # NOTE: Maintainers, please do not require google-api-core>=2.x.x - # Until this issue is closed - # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", + "google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", ] +url = "https://github.com/googleapis/python-source-context" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -49,7 +60,6 @@ if "google.cloud" in packages: namespaces.append("google.cloud") - setuptools.setup( name=name, version=version, diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.11.txt +++ b/testing/constraints-3.11.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 9368cd9..6f3158c 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -4,6 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.31.5 +google-api-core==1.33.2 proto-plus==1.22.0 protobuf==3.19.5 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt index e69de29..ed7f9ae 100644 --- a/testing/constraints-3.9.txt +++ b/testing/constraints-3.9.txt @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# This constraints file is required for unit tests. +# List all library dependencies and extras in this file. +google-api-core +proto-plus +protobuf