diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
new file mode 100644
index 0000000..efbc4b3
--- /dev/null
+++ b/.github/.OwlBot.lock.yaml
@@ -0,0 +1,3 @@
+docker:
+ image: gcr.io/repo-automation-bots/owlbot-python:latest
+ digest: sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6
\ No newline at end of file
diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml
new file mode 100644
index 0000000..7699ca2
--- /dev/null
+++ b/.github/.OwlBot.yaml
@@ -0,0 +1,19 @@
+# Copyright 2021 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.
+
+docker:
+ image: gcr.io/repo-automation-bots/owlbot-python:latest
+
+begin-after-commit-hash: d7c95df3ab1ea1b4c22a4542bad4924cc46d1388
+
diff --git a/.github/header-checker-lint.yml b/.github/header-checker-lint.yml
index fc281c0..6fe78aa 100644
--- a/.github/header-checker-lint.yml
+++ b/.github/header-checker-lint.yml
@@ -1,6 +1,6 @@
{"allowedCopyrightHolders": ["Google LLC"],
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
- "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
+ "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"],
"sourceFileExtensions": [
"ts",
"js",
diff --git a/.kokoro/release.sh b/.kokoro/release.sh
index 5bed0d7..974ebb1 100755
--- a/.kokoro/release.sh
+++ b/.kokoro/release.sh
@@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
export PYTHONUNBUFFERED=1
# Move into the package, build the distribution and upload.
-TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
+TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
cd github/python-access-context-manager
python3 setup.py sdist bdist_wheel
-twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
+twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg
index b834657..89b5a97 100644
--- a/.kokoro/release/common.cfg
+++ b/.kokoro/release/common.cfg
@@ -23,18 +23,8 @@ env_vars: {
value: "github/python-access-context-manager/.kokoro/release.sh"
}
-# Fetch PyPI password
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "google_cloud_pypi_password"
- }
- }
-}
-
# Tokens needed to report release status back to GitHub
env_vars: {
key: "SECRET_MANAGER_KEYS"
- value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
-}
\ No newline at end of file
+ value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
+}
diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg
new file mode 100644
index 0000000..9c06f5e
--- /dev/null
+++ b/.kokoro/samples/python3.9/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.9"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py39"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-access-context-manager/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-access-context-manager/.kokoro/trampoline.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.9/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg
new file mode 100644
index 0000000..f9cfcd3
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg
new file mode 100644
index 0000000..50fec96
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg
new file mode 100644
index 0000000..a1c8d97
--- /dev/null
+++ b/.kokoro/samples/python3.9/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 32302e4..62eb5a7 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,8 +1,22 @@
+# Copyright 2021 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.
+#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
+ rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -12,6 +26,6 @@ repos:
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
- rev: 3.9.0
+ rev: 3.9.2
hooks:
- id: flake8
diff --git a/.repo-metadata.json b/.repo-metadata.json
index b33cc8e..30f39ee 100644
--- a/.repo-metadata.json
+++ b/.repo-metadata.json
@@ -5,6 +5,7 @@
"issue_tracker": "https://github.com/googleapis/python-access-context-manager/issues",
"release_level": "beta",
"language": "python",
+ "library_type": "GAPIC_AUTO",
"repo": "googleapis/python-access-context-manager",
"distribution_name": "google-cloud-access-context-manager"
-}
\ No newline at end of file
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 81dbaa0..cc9fae5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,17 @@
# Changelog
+### [0.1.4](https://www.github.com/googleapis/python-access-context-manager/compare/v0.1.3...v0.1.4) (2021-06-22)
+
+
+### Bug Fixes
+
+* **deps:** require python 3.6 ([#46](https://www.github.com/googleapis/python-access-context-manager/issues/46)) ([3a4c5de](https://www.github.com/googleapis/python-access-context-manager/commit/3a4c5def322acc5bd16bdbeafef6d3235b5eadab))
+
+
+### Documentation
+
+* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-access-context-manager/issues/1127)) ([#44](https://www.github.com/googleapis/python-access-context-manager/issues/44)) ([5bd362e](https://www.github.com/googleapis/python-access-context-manager/commit/5bd362e10d1fd84f31bca28345560dbb9f71437f))
+
### [0.1.3](https://www.github.com/googleapis/python-access-context-manager/compare/v0.1.2...v0.1.3) (2021-04-14)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index d1b8096..3fb9f8e 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -69,7 +69,6 @@ We use `nox `__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::
- $ nox -s unit-2.7
$ nox -s unit-3.8
$ ...
@@ -144,7 +143,6 @@ Running System Tests
# Run all system tests
$ nox -s system-3.8
- $ nox -s system-2.7
# Run a single system test
$ nox -s system-3.8 -- -k
@@ -152,29 +150,14 @@ Running System Tests
.. note::
- System tests are only configured to run under Python 2.7 and
- Python 3.8. For expediency, we do not run them in older versions
- of Python 3.
+ System tests are only configured to run under Python 3.8.
+ For expediency, we do not run them in older versions of Python 3.
This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
run all the tests.
-- System tests will be run against an actual project and
- so you'll need to provide some environment variables to facilitate
- authentication to your project:
-
- - ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file;
- Such a file can be downloaded directly from the developer's console by clicking
- "Generate new JSON key". See private key
- `docs `__
- for more details.
-
-- Once you have downloaded your json keys, set the environment variable
- ``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file::
-
- $ export GOOGLE_APPLICATION_CREDENTIALS="/Users//path/to/app_credentials.json"
-
+- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication `__. Some tests require a service account. For those tests see `Authenticating as a service account `__.
*************
Test Coverage
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..8b58ae9
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,7 @@
+# Security Policy
+
+To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
+
+The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
+
+We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
diff --git a/docs/_static/custom.css b/docs/_static/custom.css
index bcd37bb..b0a2954 100644
--- a/docs/_static/custom.css
+++ b/docs/_static/custom.css
@@ -1,9 +1,20 @@
div#python2-eol {
border-color: red;
border-width: medium;
-}
+}
/* Ensure minimum width for 'Parameters' / 'Returns' column */
dl.field-list > dt {
min-width: 100px
}
+
+/* Insert space between methods for readability */
+dl.method {
+ padding-top: 10px;
+ padding-bottom: 10px
+}
+
+/* Insert empty space between classes */
+dl.class {
+ padding-bottom: 50px
+}
diff --git a/docs/conf.py b/docs/conf.py
index 1e1de05..968cc6e 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,4 +1,17 @@
# -*- coding: utf-8 -*-
+# Copyright 2021 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.
#
# google-cloud-access-context-manager documentation build configuration file
#
@@ -67,9 +80,9 @@
master_doc = "index"
# General information about the project.
-project = u"google-cloud-access-context-manager"
-copyright = u"2019, Google"
-author = u"Google APIs"
+project = "google-cloud-access-context-manager"
+copyright = "2019, Google"
+author = "Google APIs"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -268,7 +281,7 @@
(
master_doc,
"google-cloud-access-context-manager.tex",
- u"google-cloud-access-context-manager Documentation",
+ "google-cloud-access-context-manager Documentation",
author,
"manual",
)
@@ -303,7 +316,7 @@
(
master_doc,
"google-cloud-access-context-manager",
- u"google-cloud-access-context-manager Documentation",
+ "google-cloud-access-context-manager Documentation",
[author],
1,
)
@@ -322,7 +335,7 @@
(
master_doc,
"google-cloud-access-context-manager",
- u"google-cloud-access-context-manager Documentation",
+ "google-cloud-access-context-manager Documentation",
author,
"google-cloud-access-context-manager",
"google-cloud-access-context-manager Library",
@@ -347,13 +360,10 @@
intersphinx_mapping = {
"python": ("https://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
- "google.api_core": (
- "https://googleapis.dev/python/google-api-core/latest/",
- None,
- ),
+ "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
-
+ "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
}
diff --git a/docs/multiprocessing.rst b/docs/multiprocessing.rst
index 1cb29d4..536d17b 100644
--- a/docs/multiprocessing.rst
+++ b/docs/multiprocessing.rst
@@ -1,7 +1,7 @@
.. note::
- Because this client uses :mod:`grpcio` library, it is safe to
+ Because this client uses :mod:`grpc` library, it is safe to
share instances across threads. In multiprocessing scenarios, the best
practice is to create client instances *after* the invocation of
- :func:`os.fork` by :class:`multiprocessing.Pool` or
+ :func:`os.fork` by :class:`multiprocessing.pool.Pool` or
:class:`multiprocessing.Process`.
diff --git a/google/identity/accesscontextmanager/type/__init__.py b/google/identity/accesscontextmanager/type/__init__.py
index e4ae888..436b8cc 100644
--- a/google/identity/accesscontextmanager/type/__init__.py
+++ b/google/identity/accesscontextmanager/type/__init__.py
@@ -16,7 +16,6 @@
from __future__ import absolute_import
-import sys
from google.api_core.protobuf_helpers import get_messages
diff --git a/google/identity/accesscontextmanager/type/device_resources_pb2.py b/google/identity/accesscontextmanager/type/device_resources_pb2.py
index b79cb5d..6ce0c3e 100644
--- a/google/identity/accesscontextmanager/type/device_resources_pb2.py
+++ b/google/identity/accesscontextmanager/type/device_resources_pb2.py
@@ -38,7 +38,7 @@
serialized_options=b"\n-com.google.identity.accesscontextmanager.typeB\tTypeProtoP\001ZMgoogle.golang.org/genproto/googleapis/identity/accesscontextmanager/type;type\252\002)Google.Identity.AccessContextManager.Type\312\002)Google\\Identity\\AccessContextManager\\Type\352\002,Google::Identity::AccessContextManager::Type",
create_key=_descriptor._internal_create_key,
serialized_pb=b"\n@google/identity/accesscontextmanager/type/device_resources.proto\x12)google.identity.accesscontextmanager.type\x1a\x1cgoogle/api/annotations.proto*p\n\x16\x44\x65viceEncryptionStatus\x12\x1a\n\x16\x45NCRYPTION_UNSPECIFIED\x10\x00\x12\x1a\n\x16\x45NCRYPTION_UNSUPPORTED\x10\x01\x12\x0f\n\x0bUNENCRYPTED\x10\x02\x12\r\n\tENCRYPTED\x10\x03*\x82\x01\n\x06OsType\x12\x12\n\x0eOS_UNSPECIFIED\x10\x00\x12\x0f\n\x0b\x44\x45SKTOP_MAC\x10\x01\x12\x13\n\x0f\x44\x45SKTOP_WINDOWS\x10\x02\x12\x11\n\rDESKTOP_LINUX\x10\x03\x12\x15\n\x11\x44\x45SKTOP_CHROME_OS\x10\x06\x12\x0b\n\x07\x41NDROID\x10\x04\x12\x07\n\x03IOS\x10\x05*V\n\x15\x44\x65viceManagementLevel\x12\x1a\n\x16MANAGEMENT_UNSPECIFIED\x10\x00\x12\x08\n\x04NONE\x10\x01\x12\t\n\x05\x42\x41SIC\x10\x02\x12\x0c\n\x08\x43OMPLETE\x10\x03\x42\x92\x02\n-com.google.identity.accesscontextmanager.typeB\tTypeProtoP\x01ZMgoogle.golang.org/genproto/googleapis/identity/accesscontextmanager/type;type\xaa\x02)Google.Identity.AccessContextManager.Type\xca\x02)Google\\Identity\\AccessContextManager\\Type\xea\x02,Google::Identity::AccessContextManager::Typeb\x06proto3",
- dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR],
+ dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,],
)
_DEVICEENCRYPTIONSTATUS = _descriptor.EnumDescriptor(
diff --git a/google/identity/accesscontextmanager/v1/__init__.py b/google/identity/accesscontextmanager/v1/__init__.py
index b28d7fc..90c8729 100644
--- a/google/identity/accesscontextmanager/v1/__init__.py
+++ b/google/identity/accesscontextmanager/v1/__init__.py
@@ -16,7 +16,6 @@
from __future__ import absolute_import
-import sys
from google.api_core.protobuf_helpers import get_messages
diff --git a/google/identity/accesscontextmanager/v1/access_level_pb2.py b/google/identity/accesscontextmanager/v1/access_level_pb2.py
index 8bb0605..e6d4370 100644
--- a/google/identity/accesscontextmanager/v1/access_level_pb2.py
+++ b/google/identity/accesscontextmanager/v1/access_level_pb2.py
@@ -240,7 +240,7 @@
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[],
- )
+ ),
],
serialized_start=257,
serialized_end=569,
@@ -296,7 +296,7 @@
],
extensions=[],
nested_types=[],
- enum_types=[_BASICLEVEL_CONDITIONCOMBININGFUNCTION],
+ enum_types=[_BASICLEVEL_CONDITIONCOMBININGFUNCTION,],
serialized_options=None,
is_extendable=False,
syntax="proto3",
@@ -469,7 +469,7 @@
serialized_options=None,
file=DESCRIPTOR,
create_key=_descriptor._internal_create_key,
- )
+ ),
],
extensions=[],
nested_types=[],
diff --git a/google/identity/accesscontextmanager/v1/service_perimeter_pb2.py b/google/identity/accesscontextmanager/v1/service_perimeter_pb2.py
index a656967..75e069f 100644
--- a/google/identity/accesscontextmanager/v1/service_perimeter_pb2.py
+++ b/google/identity/accesscontextmanager/v1/service_perimeter_pb2.py
@@ -259,7 +259,7 @@
],
extensions=[],
nested_types=[],
- enum_types=[_SERVICEPERIMETER_PERIMETERTYPE],
+ enum_types=[_SERVICEPERIMETER_PERIMETERTYPE,],
serialized_options=None,
is_extendable=False,
syntax="proto3",
@@ -415,7 +415,7 @@
),
],
extensions=[],
- nested_types=[_SERVICEPERIMETERCONFIG_VPCACCESSIBLESERVICES],
+ nested_types=[_SERVICEPERIMETERCONFIG_VPCACCESSIBLESERVICES,],
enum_types=[],
serialized_options=None,
is_extendable=False,
diff --git a/noxfile.py b/noxfile.py
index e21cb54..3409852 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -1,4 +1,6 @@
-# Copyright 2020 Google LLC
+# -*- coding: utf-8 -*-
+#
+# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,80 +14,85 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# Generated by synthtool. DO NOT EDIT!
+
+from __future__ import absolute_import
import os
+import pathlib
import shutil
-import pathlib
-from pathlib import Path
import nox
-BLACK_VERSION = "black==19.3b0"
-CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
+BLACK_VERSION = "black==19.10b0"
+BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"]
+DEFAULT_PYTHON_VERSION = "3.8"
+SYSTEM_TEST_PYTHON_VERSIONS = ["2.7", "3.8"]
+UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]
-@nox.session(python="3.8")
-def blacken(session):
- """Run black.
- Format code to uniform standard.
- This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
- That run uses an image that doesn't have 3.6 installed. Before updating this
- check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
- """
- session.install(BLACK_VERSION)
- session.run("black", "google", "setup.py")
+CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()
+# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
+nox.options.sessions = [
+ "system",
+ "lint",
+ "test",
+ "generate_protos",
+ "lint_setup_py",
+ "blacken",
+ "docs",
+]
-@nox.session(python="3.8")
-def lint_setup_py(session):
- """Verify that setup.py is valid"""
- session.install("docutils", "pygments")
- session.run("python", "setup.py", "check", "--strict")
+# Error if a python version is missing
+nox.options.error_on_missing_interpreters = True
-@nox.session(python="3.7")
-def docs(session):
- """Build the docs for this library."""
+@nox.session(python=DEFAULT_PYTHON_VERSION)
+def lint(session):
+ """Run linters.
- session.install("-e", ".")
- session.install("sphinx<3.0.0", "alabaster", "recommonmark")
+ Returns a failure if the linters find linting errors or sufficiently
+ serious code quality issues.
+ """
+ session.install("flake8", BLACK_VERSION)
+ session.run(
+ "black", "--check", *BLACK_PATHS,
+ )
+ session.run("flake8", "google", "tests")
- shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
+
+@nox.session(python=DEFAULT_PYTHON_VERSION)
+def blacken(session):
+ """Run black. Format code to uniform standard."""
+ session.install(BLACK_VERSION)
session.run(
- "sphinx-build",
- "-W", # warnings as errors
- "-T", # show full traceback on exception
- "-N", # no colors
- "-b",
- "html",
- "-d",
- os.path.join("docs", "_build", "doctrees", ""),
- os.path.join("docs", ""),
- os.path.join("docs", "_build", "html", ""),
+ "black", *BLACK_PATHS,
)
+@nox.session(python=DEFAULT_PYTHON_VERSION)
+def lint_setup_py(session):
+ """Verify that setup.py is valid (including RST check)."""
+ session.install("docutils", "pygments")
+ session.run("python", "setup.py", "check", "--restructuredtext", "--strict")
+
+
def default(session):
# Install all test dependencies, then install this package in-place.
- session.install("asyncmock", "pytest-asyncio")
-
- session.install(
- "mock", "pytest", "pytest-cov",
- )
- session.install("-e", ".")
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
+ session.install("mock", "pytest", "pytest-cov", "-c", constraints_path)
- # Install this package
- # This *must* be the last install command to get the package from source.
- session.install("e", "..", "-c", constraints_path)
+ session.install("-e", ".", "-c", constraints_path)
# Run py.test against the unit tests.
session.run(
"py.test",
"--quiet",
+ f"--junitxml=unit_{session.python}_sponge_log.xml",
"--cov=google/cloud",
"--cov=tests/unit",
"--cov-append",
@@ -102,49 +109,6 @@ def unit(session):
default(session)
-def system(session):
- """Run the system test suite."""
- system_test_path = os.path.join("tests", "system.py")
- system_test_folder_path = os.path.join("tests", "system")
-
- # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
- if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
- session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
- # Sanity check: Only run tests if the environment variable is set.
- if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
- session.skip("Credentials must be set via environment variable")
-
- system_test_exists = os.path.exists(system_test_path)
- system_test_folder_exists = os.path.exists(system_test_folder_path)
- # Sanity check: only run tests if found.
- if not system_test_exists and not system_test_folder_exists:
- session.skip("System tests were not found")
-
- # Use pre-release gRPC for system tests.
- session.install("--pre", "grpcio")
-
- # Install all test dependencies, then install this package into the
- # virtualenv's dist-packages.
- session.install(
- "mock", "pytest", "google-cloud-testutils",
- )
- session.install("-e", ".")
-
- constraints_path = str(
- CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
- )
-
- # Install this package
- # This *must* be the last install command to get the package from source.
- session.install("e", "..", "-c", constraints_path)
-
- # Run py.test against the system tests.
- if system_test_exists:
- session.run("py.test", "--quiet", system_test_path, *session.posargs)
- if system_test_folder_exists:
- session.run("py.test", "--quiet", system_test_folder_path, *session.posargs)
-
-
@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
@nox.parametrize(
"library", ["python-asset"], ids=["asset"],
@@ -177,7 +141,6 @@ def test(session, library):
@nox.session(python="3.8")
def generate_protos(session):
"""Generates the protos using protoc.
-
Some notes on the `google` directory:
1. The `_pb2.py` files are produced by protoc.
2. The .proto files are non-functional but are left in the repository
@@ -187,7 +150,7 @@ def generate_protos(session):
files.
"""
session.install("grpcio-tools")
- protos = [str(p) for p in (Path(".").glob("google/**/*.proto"))]
+ protos = [str(p) for p in (pathlib.Path(".").glob("google/**/*.proto"))]
# Clone googleapis/api-common-protos
api_common_protos = "api-common-protos"
@@ -211,3 +174,109 @@ def generate_protos(session):
"--python_out=.",
*protos,
)
+
+
+@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)
+def system(session):
+ """Run the system test suite."""
+ constraints_path = str(
+ CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
+ )
+ system_test_path = os.path.join("tests", "system.py")
+ system_test_folder_path = os.path.join("tests", "system")
+
+ # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
+ if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
+ session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
+ # Install pyopenssl for mTLS testing.
+ if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
+ session.install("pyopenssl")
+
+ system_test_exists = os.path.exists(system_test_path)
+ system_test_folder_exists = os.path.exists(system_test_folder_path)
+ # Sanity check: only run tests if found.
+ if not system_test_exists and not system_test_folder_exists:
+ session.skip("System tests were not found")
+
+ # Use pre-release gRPC for system tests.
+ session.install("--pre", "grpcio")
+
+ # Install all test dependencies, then install this package into the
+ # virtualenv's dist-packages.
+ session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path)
+ session.install("-e", ".", "-c", constraints_path)
+
+ # Run py.test against the system tests.
+ if system_test_exists:
+ session.run(
+ "py.test",
+ "--quiet",
+ f"--junitxml=system_{session.python}_sponge_log.xml",
+ system_test_path,
+ *session.posargs,
+ )
+ if system_test_folder_exists:
+ session.run(
+ "py.test",
+ "--quiet",
+ f"--junitxml=system_{session.python}_sponge_log.xml",
+ system_test_folder_path,
+ *session.posargs,
+ )
+
+
+@nox.session(python=DEFAULT_PYTHON_VERSION)
+def docs(session):
+ """Build the docs for this library."""
+
+ session.install("-e", ".")
+ session.install("sphinx==4.0.1", "alabaster", "recommonmark")
+
+ shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
+ session.run(
+ "sphinx-build",
+ "-W", # warnings as errors
+ "-T", # show full traceback on exception
+ "-N", # no colors
+ "-b",
+ "html",
+ "-d",
+ os.path.join("docs", "_build", "doctrees", ""),
+ os.path.join("docs", ""),
+ os.path.join("docs", "_build", "html", ""),
+ )
+
+
+@nox.session(python=DEFAULT_PYTHON_VERSION)
+def docfx(session):
+ """Build the docfx yaml files for this library."""
+
+ session.install("-e", ".")
+ session.install(
+ "sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml"
+ )
+
+ shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
+ session.run(
+ "sphinx-build",
+ "-T", # show full traceback on exception
+ "-N", # no colors
+ "-D",
+ (
+ "extensions=sphinx.ext.autodoc,"
+ "sphinx.ext.autosummary,"
+ "docfx_yaml.extension,"
+ "sphinx.ext.intersphinx,"
+ "sphinx.ext.coverage,"
+ "sphinx.ext.napoleon,"
+ "sphinx.ext.todo,"
+ "sphinx.ext.viewcode,"
+ "recommonmark"
+ ),
+ "-b",
+ "html",
+ "-d",
+ os.path.join("docs", "_build", "doctrees", ""),
+ os.path.join("docs", ""),
+ os.path.join("docs", "_build", "html", ""),
+ )
diff --git a/owlbot.py b/owlbot.py
new file mode 100644
index 0000000..c94f6f6
--- /dev/null
+++ b/owlbot.py
@@ -0,0 +1,184 @@
+# Copyright 2020 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
+#
+# 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 re
+
+import synthtool as s
+import synthtool.gcp as gcp
+from synthtool import tmp
+from synthtool.languages import python
+from synthtool.sources import git
+
+# ----------------------------------------------------------------------------
+# Add templated files
+# ----------------------------------------------------------------------------
+common = gcp.CommonTemplates()
+templated_files = common.py_library()
+s.move(
+ templated_files, excludes=[".coveragerc", ".gitignore",],
+)
+
+# ----------------------------------------------------------------------------
+# Customize noxfile.py
+# ----------------------------------------------------------------------------
+
+old_sessions = """
+ "unit",
+ "system",
+ "cover",
+ "lint",
+"""
+
+new_sessions = """
+ "system",
+ "lint",
+ "test",
+ "generate_protos",
+"""
+
+# Remove `unit` and `cover` sessions.
+# Add `test` and `generate_protos` sessions.
+s.replace("noxfile.py", old_sessions, new_sessions)
+
+# Remove unit* sessions
+s.replace("noxfile.py",
+ """@nox.session\(python=UNIT_TEST_PYTHON_VERSIONS\)
+def unit\(session\):""",
+ """def unit(session):""",
+)
+
+# Remove cover session
+s.replace("noxfile.py",
+ """@nox.session\(python=DEFAULT_PYTHON_VERSION\)
+def cover.*
+ session.run\("coverage", "erase"\)""",
+ """""",
+ flags=re.MULTILINE | re.DOTALL,
+)
+
+def place_before(path, text, *before_text, escape=None):
+ replacement = "\n".join(before_text) + "\n" + text
+ if escape:
+ for c in escape:
+ text = text.replace(c, '\\' + c)
+ s.replace([path], text, replacement)
+
+custom_nox_sessions = """
+@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
+@nox.parametrize(
+ "library", ["python-asset"], ids=["asset"],
+)
+def test(session, library):
+ \"\"\"Run tests from a downstream libraries.
+ To verify that any changes we make here will not break downstream libraries, clone
+ a few and run their unit and system tests.
+ NOTE: The unit and system test functions above are copied from the templates.
+ They will need to be updated when the templates change.
+ \"\"\"
+ try:
+ session.run("git", "-C", library, "pull", external=True)
+ except nox.command.CommandFailed:
+ session.run(
+ "git",
+ "clone",
+ "--single-branch",
+ f"https://github.com/googleapis/{library}",
+ external=True,
+ )
+
+ session.cd(library)
+ unit(session)
+ # system tests are run 3.7 only
+ if session.python == "3.7":
+ system(session)
+
+
+@nox.session(python="3.8")
+def generate_protos(session):
+ \"\"\"Generates the protos using protoc.
+ Some notes on the `google` directory:
+ 1. The `_pb2.py` files are produced by protoc.
+ 2. The .proto files are non-functional but are left in the repository
+ to make it easier to understand diffs.
+ 3. The `google` directory also has `__init__.py` files to create proper modules.
+ If a new subdirectory is added, you will need to create more `__init__.py`
+ files.
+ \"\"\"
+ session.install("grpcio-tools")
+ protos = [str(p) for p in (pathlib.Path(".").glob("google/**/*.proto"))]
+
+ # Clone googleapis/api-common-protos
+ api_common_protos = "api-common-protos"
+ try:
+ session.run("git", "-C", api_common_protos, "pull", external=True)
+ except nox.command.CommandFailed:
+ session.run(
+ "git",
+ "clone",
+ "--single-branch",
+ f"https://github.com/googleapis/{api_common_protos}",
+ external=True,
+ )
+
+ session.run(
+ "python",
+ "-m",
+ "grpc_tools.protoc",
+ "--proto_path=api-common-protos",
+ "--proto_path=.",
+ "--python_out=.",
+ *protos,
+ )
+"""
+
+# `google-cloud-context-manager` contains only protos
+# and has a customized `test` session to test
+# downstream client `google-cloud-asset`
+place_before(
+ "noxfile.py",
+ "@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS)\n"
+ "def system(session):",
+ custom_nox_sessions,
+ escape="()"
+)
+
+s.shell.run(["nox", "-s", "generate_protos"])
+s.shell.run(["nox", "-s", "blacken"], hide_output=False)
+
+# Add license headers
+python.fix_pb2_headers()
+
+LICENSE = """
+# Copyright 2020 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."""
+
+PB2_GRPC_HEADER = r"""(\# Generated by the gRPC Python protocol compiler plugin\. DO NOT EDIT!$)
+(.*?$)"""
+
+s.replace(
+ "**/*_pb2_grpc.py",
+ PB2_GRPC_HEADER,
+ fr"{LICENSE}\n\n\g<1>\n\n\g<2>", # add line breaks to avoid stacking replacements
+)
diff --git a/renovate.json b/renovate.json
index f08bc22..c048955 100644
--- a/renovate.json
+++ b/renovate.json
@@ -2,5 +2,8 @@
"extends": [
"config:base", ":preserveSemverRanges"
],
- "ignorePaths": [".pre-commit-config.yaml"]
+ "ignorePaths": [".pre-commit-config.yaml"],
+ "pip_requirements": {
+ "fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"]
+ }
}
diff --git a/setup.py b/setup.py
index 4c2e714..2e0ea9c 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@
name = "google-cloud-access-context-manager"
description = "Google Cloud Access Context Manager Protobufs"
-version = "0.1.3"
+version = "0.1.4"
# Should be one of:
# 'Development Status :: 3 - Alpha'
# 'Development Status :: 4 - Beta'
@@ -62,10 +62,10 @@
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
"Operating System :: OS Independent",
"Topic :: Internet",
],
@@ -73,7 +73,7 @@
packages=packages,
namespace_packages=namespaces,
install_requires=dependencies,
- python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*",
+ python_requires=">=3.6",
include_package_data=True,
zip_safe=False,
)
diff --git a/synth.metadata b/synth.metadata
deleted file mode 100644
index e7cd8df..0000000
--- a/synth.metadata
+++ /dev/null
@@ -1,95 +0,0 @@
-{
- "sources": [
- {
- "git": {
- "name": ".",
- "remote": "https://github.com/googleapis/python-access-context-manager.git",
- "sha": "990780dc21637b4dfac25fb0b1d56aa5f27faed5"
- }
- },
- {
- "git": {
- "name": "synthtool",
- "remote": "https://github.com/googleapis/synthtool.git",
- "sha": "f5c5904fb0c6aa3b3730eadf4e5a4485afc65726"
- }
- },
- {
- "git": {
- "name": "synthtool",
- "remote": "https://github.com/googleapis/synthtool.git",
- "sha": "f5c5904fb0c6aa3b3730eadf4e5a4485afc65726"
- }
- }
- ],
- "generatedFiles": [
- ".flake8",
- ".github/CONTRIBUTING.md",
- ".github/ISSUE_TEMPLATE/bug_report.md",
- ".github/ISSUE_TEMPLATE/feature_request.md",
- ".github/ISSUE_TEMPLATE/support_request.md",
- ".github/PULL_REQUEST_TEMPLATE.md",
- ".github/header-checker-lint.yml",
- ".github/release-please.yml",
- ".github/snippet-bot.yml",
- ".kokoro/build.sh",
- ".kokoro/continuous/common.cfg",
- ".kokoro/continuous/continuous.cfg",
- ".kokoro/docker/docs/Dockerfile",
- ".kokoro/docker/docs/fetch_gpg_keys.sh",
- ".kokoro/docs/common.cfg",
- ".kokoro/docs/docs-presubmit.cfg",
- ".kokoro/docs/docs.cfg",
- ".kokoro/populate-secrets.sh",
- ".kokoro/presubmit/common.cfg",
- ".kokoro/presubmit/presubmit.cfg",
- ".kokoro/publish-docs.sh",
- ".kokoro/release.sh",
- ".kokoro/release/common.cfg",
- ".kokoro/release/release.cfg",
- ".kokoro/samples/lint/common.cfg",
- ".kokoro/samples/lint/continuous.cfg",
- ".kokoro/samples/lint/periodic.cfg",
- ".kokoro/samples/lint/presubmit.cfg",
- ".kokoro/samples/python3.6/common.cfg",
- ".kokoro/samples/python3.6/continuous.cfg",
- ".kokoro/samples/python3.6/periodic-head.cfg",
- ".kokoro/samples/python3.6/periodic.cfg",
- ".kokoro/samples/python3.6/presubmit.cfg",
- ".kokoro/samples/python3.7/common.cfg",
- ".kokoro/samples/python3.7/continuous.cfg",
- ".kokoro/samples/python3.7/periodic-head.cfg",
- ".kokoro/samples/python3.7/periodic.cfg",
- ".kokoro/samples/python3.7/presubmit.cfg",
- ".kokoro/samples/python3.8/common.cfg",
- ".kokoro/samples/python3.8/continuous.cfg",
- ".kokoro/samples/python3.8/periodic-head.cfg",
- ".kokoro/samples/python3.8/periodic.cfg",
- ".kokoro/samples/python3.8/presubmit.cfg",
- ".kokoro/test-samples-against-head.sh",
- ".kokoro/test-samples-impl.sh",
- ".kokoro/test-samples.sh",
- ".kokoro/trampoline.sh",
- ".kokoro/trampoline_v2.sh",
- ".pre-commit-config.yaml",
- ".trampolinerc",
- "CODE_OF_CONDUCT.md",
- "CONTRIBUTING.rst",
- "LICENSE",
- "MANIFEST.in",
- "docs/_static/custom.css",
- "docs/_templates/layout.html",
- "docs/conf.py",
- "docs/multiprocessing.rst",
- "renovate.json",
- "scripts/decrypt-secrets.sh",
- "scripts/readme-gen/readme_gen.py",
- "scripts/readme-gen/templates/README.tmpl.rst",
- "scripts/readme-gen/templates/auth.tmpl.rst",
- "scripts/readme-gen/templates/auth_api_key.tmpl.rst",
- "scripts/readme-gen/templates/install_deps.tmpl.rst",
- "scripts/readme-gen/templates/install_portaudio.tmpl.rst",
- "setup.cfg",
- "testing/.gitignore"
- ]
-}
\ No newline at end of file
diff --git a/synth.py b/synth.py
deleted file mode 100644
index d8a447a..0000000
--- a/synth.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2020 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
-#
-# 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 synthtool as s
-import synthtool.gcp as gcp
-from synthtool import tmp
-from synthtool.languages import python
-from synthtool.sources import git
-
-# ----------------------------------------------------------------------------
-# Add templated files
-# ----------------------------------------------------------------------------
-common = gcp.CommonTemplates()
-templated_files = common.py_library()
-s.move(
- templated_files, excludes=["noxfile.py", ".coveragerc", ".gitignore",],
-)
-
-s.shell.run(["nox", "-s", "generate_protos"])
-s.shell.run(["nox", "-s", "blacken"], hide_output=False)
-
-# Add license headers
-python.fix_pb2_headers()
-
-LICENSE = """
-# Copyright 2020 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."""
-
-PB2_GRPC_HEADER = r"""(\# Generated by the gRPC Python protocol compiler plugin\. DO NOT EDIT!$)
-(.*?$)"""
-
-s.replace(
- "**/*_pb2_grpc.py",
- PB2_GRPC_HEADER,
- fr"{LICENSE}\n\n\g<1>\n\n\g<2>", # add line breaks to avoid stacking replacements
-)
diff --git a/tests/.gitkeep b/tests/.gitkeep
new file mode 100644
index 0000000..e69de29