Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat: add support for python 3.10 (#131)
Browse files Browse the repository at this point in the history
* feat: add support for python 3.10

* add constraints files for python 3.10 and 3.11
  • Loading branch information
parthea committed Oct 14, 2021
1 parent dece849 commit 703ac17
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .kokoro/samples/lint/common.cfg
Expand Up @@ -31,4 +31,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-compute/.kokoro/trampoline.sh"
build_file: "python-compute/.kokoro/trampoline_v2.sh"
40 changes: 40 additions & 0 deletions .kokoro/samples/python3.10/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.10"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-310"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-compute/.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-compute/.kokoro/trampoline_v2.sh"
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.10/continuous.cfg
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
11 changes: 11 additions & 0 deletions .kokoro/samples/python3.10/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-compute/.kokoro/test-samples-against-head.sh"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.10/periodic.cfg
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.10/presubmit.cfg
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.6/common.cfg
Expand Up @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-compute/.kokoro/trampoline.sh"
build_file: "python-compute/.kokoro/trampoline_v2.sh"
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.6/periodic.cfg
Expand Up @@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
}
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.7/common.cfg
Expand Up @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-compute/.kokoro/trampoline.sh"
build_file: "python-compute/.kokoro/trampoline_v2.sh"
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.7/periodic.cfg
Expand Up @@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
}
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.8/common.cfg
Expand Up @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-compute/.kokoro/trampoline.sh"
build_file: "python-compute/.kokoro/trampoline_v2.sh"
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.8/periodic.cfg
Expand Up @@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
}
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.9/common.cfg
Expand Up @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-compute/.kokoro/trampoline.sh"
build_file: "python-compute/.kokoro/trampoline_v2.sh"
2 changes: 1 addition & 1 deletion .kokoro/samples/python3.9/periodic.cfg
Expand Up @@ -3,4 +3,4 @@
env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
}
2 changes: 0 additions & 2 deletions .kokoro/test-samples-against-head.sh
Expand Up @@ -23,6 +23,4 @@ set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

cd github/python-compute

exec .kokoro/test-samples-impl.sh
2 changes: 0 additions & 2 deletions .kokoro/test-samples.sh
Expand Up @@ -24,8 +24,6 @@ set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

cd github/python-compute

# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
# preserving the test runner implementation.
Expand Down
17 changes: 14 additions & 3 deletions .trampolinerc
Expand Up @@ -16,15 +16,26 @@

# Add required env vars here.
required_envvars+=(
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
)

# Add env vars which are passed down into the container here.
pass_down_envvars+=(
"NOX_SESSION"
###############
# Docs builds
###############
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
"NOX_SESSION"
##################
# Samples builds
##################
"INSTALL_LIBRARY_FROM_SOURCE"
"RUN_TESTS_SESSION"
"BUILD_SPECIFIC_GCLOUD_PROJECT"
# Target directories.
"RUN_TESTS_DIRS"
# The nox session to run.
"RUN_TESTS_SESSION"
)

# Prevent unintentional override on the default image.
Expand Down
6 changes: 4 additions & 2 deletions CONTRIBUTING.rst
Expand Up @@ -22,7 +22,7 @@ In order to add a feature:
documentation.

- The feature must work fully on the following CPython versions:
3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows.
3.6, 3.7, 3.8, 3.9 and 3.10 on both UNIX and Windows.

- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
Expand Down Expand Up @@ -72,7 +72,7 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.

- To run a single unit test::

$ nox -s unit-3.9 -- -k <name of test>
$ nox -s unit-3.10 -- -k <name of test>


.. note::
Expand Down Expand Up @@ -225,11 +225,13 @@ We support:
- `Python 3.7`_
- `Python 3.8`_
- `Python 3.9`_
- `Python 3.10`_

.. _Python 3.6: https://docs.python.org/3.6/
.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/
.. _Python 3.10: https://docs.python.org/3.10/


Supported versions can be found in our ``noxfile.py`` `config`_.
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Expand Up @@ -29,7 +29,7 @@

DEFAULT_PYTHON_VERSION = "3.8"
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]

CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute()

Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/noxfile.py
Expand Up @@ -87,7 +87,7 @@ def get_pytest_env_vars() -> Dict[str, str]:

# DO NOT EDIT - automatically generated.
# All versions used to test samples.
ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
Expand Down
4 changes: 4 additions & 0 deletions setup.py
Expand Up @@ -56,9 +56,13 @@
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand Down
54 changes: 0 additions & 54 deletions synth.py
Expand Up @@ -45,60 +45,6 @@
templated_files, excludes=[".coveragerc"] # the microgenerator has a good coveragerc file
)

# Remove the replacements below once https://github.com/googleapis/synthtool/pull/1188 is merged

# Update googleapis/repo-automation-bots repo to main in .kokoro/*.sh files
s.replace(".kokoro/*.sh", "repo-automation-bots/tree/master", "repo-automation-bots/tree/main")

# Customize CONTRIBUTING.rst to replace master with main
s.replace(
"CONTRIBUTING.rst",
"fetch and merge changes from upstream into master",
"fetch and merge changes from upstream into main",
)

s.replace(
"CONTRIBUTING.rst",
"git merge upstream/master",
"git merge upstream/main",
)

s.replace(
"CONTRIBUTING.rst",
"""export GOOGLE_CLOUD_TESTING_BRANCH=\"master\"""",
"""export GOOGLE_CLOUD_TESTING_BRANCH=\"main\"""",
)

s.replace(
"CONTRIBUTING.rst",
"remote \(``master``\)",
"remote (``main``)",
)

s.replace(
"CONTRIBUTING.rst",
"blob/master/CONTRIBUTING.rst",
"blob/main/CONTRIBUTING.rst",
)

s.replace(
"CONTRIBUTING.rst",
"blob/master/noxfile.py",
"blob/main/noxfile.py",
)

s.replace(
"docs/conf.py",
"master_doc",
"root_doc",
)

s.replace(
"docs/conf.py",
"# The master toctree document.",
"# The root toctree document.",
)

# --------------------------------------------------------------------------
# Samples templates
# --------------------------------------------------------------------------
Expand Down
Empty file added testing/constraints-3.10.txt
Empty file.
Empty file added testing/constraints-3.11.txt
Empty file.

0 comments on commit 703ac17

Please sign in to comment.