Skip to content

Commit 4f89b13

Browse files
authored
fix(python): drop python 3.6 (#1447)
1 parent f3f0bd6 commit 4f89b13

File tree

14 files changed

+159
-134
lines changed

14 files changed

+159
-134
lines changed

synthtool/gcp/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def py_library(self, **kwargs) -> Path:
238238
if "default_python_version" not in kwargs:
239239
kwargs["default_python_version"] = "3.8"
240240
if "unit_test_python_versions" not in kwargs:
241-
kwargs["unit_test_python_versions"] = ["3.6", "3.7", "3.8", "3.9", "3.10"]
241+
kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10"]
242242

243243
if "system_test_python_versions" not in kwargs:
244244
kwargs["system_test_python_versions"] = ["3.8"]

synthtool/gcp/templates/python_library/.kokoro/samples/python3.6/common.cfg

-51
This file was deleted.

synthtool/gcp/templates/python_library/.kokoro/samples/python3.6/continuous.cfg

-7
This file was deleted.

synthtool/gcp/templates/python_library/.kokoro/samples/python3.6/periodic-head.cfg

-18
This file was deleted.

synthtool/gcp/templates/python_library/.kokoro/samples/python3.6/periodic.cfg

-13
This file was deleted.

synthtool/gcp/templates/python_library/.kokoro/samples/python3.6/presubmit.cfg

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
Python Client for {{ metadata['repo']['name_pretty'] }} API
2+
======================{% for i in range(metadata['repo']['name_pretty']|length) %}={% endfor %}
3+
4+
|{{ metadata['repo']['release_level'] }}| |pypi| |versions|
5+
6+
`{{ metadata['repo']['name_pretty'] }} API`_: {% if metadata['repo']['api_description'] %}{{metadata['repo']['api_description'] }}{% endif %}
7+
8+
- `Client Library Documentation`_
9+
- `Product Documentation`_
10+
11+
.. |{{ metadata['repo']['release_level'] }}| image:: https://img.shields.io/badge/support-{{ metadata['repo']['release_level'] }}-{% if metadata['repo']['release_level'] == 'stable' %}gold{% else %}orange{% endif %}.svg
12+
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
13+
.. |pypi| image:: https://img.shields.io/pypi/v/{{ metadata['repo']['distribution_name'] }}.svg
14+
:target: https://pypi.org/project/{{ metadata['repo']['distribution_name'] }}/
15+
.. |versions| image:: https://img.shields.io/pypi/pyversions/{{ metadata['repo']['distribution_name'] }}.svg
16+
:target: https://pypi.org/project/{{ metadata['repo']['distribution_name'] }}/
17+
.. _{{ metadata['repo']['name_pretty'] }} API: {{ metadata['repo']['product_documentation'] }}
18+
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/{{ metadata['repo']['api_shortname'] }}/latest
19+
.. _Product Documentation: {{ metadata['repo']['product_documentation'] }}
20+
21+
Quick Start
22+
-----------
23+
24+
In order to use this library, you first need to go through the following steps:
25+
26+
1. `Select or create a Cloud Platform project.`_
27+
2. `Enable billing for your project.`_
28+
3. `Enable the {{ metadata['repo']['name_pretty'] }} API.`_
29+
4. `Setup Authentication.`_
30+
31+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
32+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
33+
.. _Enable the {{ metadata['repo']['name_pretty'] }} API.: {{ metadata['repo']['product_documentation'] }}
34+
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
35+
36+
Installation
37+
~~~~~~~~~~~~
38+
39+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
40+
create isolated Python environments. The basic problem it addresses is one of
41+
dependencies and versions, and indirectly permissions.
42+
43+
With `virtualenv`_, it's possible to install this library without needing system
44+
install permissions, and without clashing with the installed system
45+
dependencies.
46+
47+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
48+
49+
50+
Code samples and snippets
51+
~~~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
Code samples and snippets live in the `samples/` folder.
54+
55+
56+
Supported Python Versions
57+
^^^^^^^^^^^^^^^^^^^^^^^^^
58+
Our client libraries are compatible with all current [active](https://devguide.python.org/devcycle/#in-development-main-branch) and [maintenance](https://devguide.python.org/devcycle/#maintenance-branches) versions of
59+
Python.
60+
61+
Python >= 3.7
62+
63+
Unsupported Python Versions
64+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+
Python <= 3.6
66+
67+
If you are using an [end-of-life](https://devguide.python.org/devcycle/#end-of-life-branches)
68+
version of Python, we recommend that you update as soon as possible to an actively supported version.
69+
70+
71+
Mac/Linux
72+
^^^^^^^^^
73+
74+
.. code-block:: console
75+
76+
pip install virtualenv
77+
virtualenv <your-env>
78+
source <your-env>/bin/activate
79+
<your-env>/bin/pip install {{ metadata['repo']['distribution_name'] }}
80+
81+
82+
Windows
83+
^^^^^^^
84+
85+
.. code-block:: console
86+
87+
pip install virtualenv
88+
virtualenv <your-env>
89+
<your-env>\Scripts\activate
90+
<your-env>\Scripts\pip.exe install {{ metadata['repo']['distribution_name'] }}
91+
92+
Next Steps
93+
~~~~~~~~~~
94+
95+
- Read the `Client Library Documentation`_ for {{ metadata['repo']['name_pretty'] }} API
96+
to see other available methods on the client.
97+
- Read the `{{ metadata['repo']['name_pretty'] }} API Product documentation`_ to learn
98+
more about the product and see How-to Guides.
99+
- View this `README`_ to see the full list of Cloud
100+
APIs that we cover.
101+
102+
.. _{{ metadata['repo']['name_pretty'] }} API Product documentation: {{ metadata['repo']['product_documentation'] }}
103+
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst

synthtool/gcp/templates/python_library/noxfile.py.j2

+49-30
Original file line numberDiff line numberDiff line change
@@ -346,28 +346,11 @@ def docfx(session):
346346
def prerelease_deps(session):
347347
"""Run all tests with prerelease versions of dependencies installed."""
348348

349-
prerel_deps = [
350-
"protobuf",
351-
"googleapis-common-protos",
352-
"google-auth",
353-
"grpcio",
354-
"grpcio-status",
355-
"google-api-core",
356-
"proto-plus",
357-
# dependencies of google-auth
358-
"cryptography",
359-
"pyasn1",
360-
]
361-
362-
for dep in prerel_deps:
363-
session.install("--pre", "--no-deps", "--upgrade", dep)
364-
365-
# Remaining dependencies
366-
other_deps = ["requests"]
367-
session.install(*other_deps)
368-
349+
# Install all dependencies
350+
session.install("-e", ".[all, tests, tracing]")
369351
session.install(*UNIT_TEST_STANDARD_DEPENDENCIES)
370-
session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES)
352+
system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
353+
session.install(*system_deps_all)
371354

372355
# Because we test minimum dependency versions on the minimum Python
373356
# version, the first version we test with in the unit tests sessions has a
@@ -381,19 +364,44 @@ def prerelease_deps(session):
381364
constraints_text = constraints_file.read()
382365

383366
# Ignore leading whitespace and comment lines.
384-
deps = [
367+
constraints_deps = [
385368
match.group(1)
386369
for match in re.finditer(
387370
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
388371
)
389372
]
390373

391-
# Don't overwrite prerelease packages.
392-
deps = [dep for dep in deps if dep not in prerel_deps]
393-
# We use --no-deps to ensure that pre-release versions aren't overwritten
394-
# by the version ranges in setup.py.
395-
session.install(*deps)
396-
session.install("--no-deps", "-e", ".[all]")
374+
session.install(*constraints_deps)
375+
376+
if os.path.exists("samples/snippets/requirements.txt"):
377+
session.install("-r", "samples/snippets/requirements.txt")
378+
379+
if os.path.exists("samples/snippets/requirements-test.txt"):
380+
session.install("-r", "samples/snippets/requirements-test.txt")
381+
382+
prerel_deps = [
383+
"protobuf",
384+
# dependency of grpc
385+
"six",
386+
"googleapis-common-protos",
387+
"grpcio",
388+
"grpcio-status",
389+
"google-api-core",
390+
"proto-plus",
391+
"google-cloud-testutils",
392+
# dependencies of google-cloud-testutils"
393+
"click",
394+
]
395+
396+
for dep in prerel_deps:
397+
session.install("--pre", "--no-deps", "--upgrade", dep)
398+
399+
# Remaining dependencies
400+
other_deps = [
401+
"requests",
402+
"google-auth",
403+
]
404+
session.install(*other_deps)
397405

398406
# Print out prerelease package versions
399407
session.run(
@@ -402,5 +410,16 @@ def prerelease_deps(session):
402410
session.run("python", "-c", "import grpc; print(grpc.__version__)")
403411

404412
session.run("py.test", "tests/unit")
405-
session.run("py.test", "tests/system")
406-
session.run("py.test", "samples/snippets")
413+
414+
system_test_path = os.path.join("tests", "system.py")
415+
system_test_folder_path = os.path.join("tests", "system")
416+
417+
# Only run system tests if found.
418+
if os.path.exists(system_test_path) or os.path.exists(system_test_folder_path):
419+
session.run("py.test", "tests/system")
420+
421+
snippets_test_path = os.path.join("samples", "snippets")
422+
423+
# Only run samples tests if found.
424+
if os.path.exists(snippets_test_path):
425+
session.run("py.test", "samples/snippets")

synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Install Dependencies
1212
.. _Python Development Environment Setup Guide:
1313
https://cloud.google.com/python/setup
1414

15-
#. Create a virtualenv. Samples are compatible with Python 3.6+.
15+
#. Create a virtualenv. Samples are compatible with Python 3.7+.
1616

1717
.. code-block:: bash
1818
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-aiplatform==1.15.0
1+
google-cloud-aiplatform==1.15.0

synthtool/gcp/templates/python_samples/install_deps.tmpl.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Install Dependencies
1212
.. _Python Development Environment Setup Guide:
1313
https://cloud.google.com/python/setup
1414

15-
#. Create a virtualenv. Samples are compatible with Python 3.6+.
15+
#. Create a virtualenv. Samples are compatible with Python 3.7+.
1616

1717
.. code-block:: bash
1818

synthtool/gcp/templates/python_samples/noxfile.py.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
8989

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

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]

tests/fixtures/python_library/setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"License :: OSI Approved :: Apache Software License",
8989
"Programming Language :: Python",
9090
"Programming Language :: Python :: 3",
91-
"Programming Language :: Python :: 3.6",
9291
"Programming Language :: Python :: 3.7",
9392
"Programming Language :: Python :: 3.8",
9493
"Programming Language :: Python :: 3.9",
@@ -101,7 +100,7 @@
101100
namespace_packages=namespaces,
102101
install_requires=dependencies,
103102
extras_require=extras,
104-
python_requires=">=3.6",
103+
python_requires=">=3.7",
105104
scripts=["scripts/fixup_keywords.py"],
106105
include_package_data=True,
107106
zip_safe=False,

tests/fixtures/python_library_w_version_py/setup.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888
"License :: OSI Approved :: Apache Software License",
8989
"Programming Language :: Python",
9090
"Programming Language :: Python :: 3",
91-
"Programming Language :: Python :: 3.6",
9291
"Programming Language :: Python :: 3.7",
9392
"Programming Language :: Python :: 3.8",
9493
"Programming Language :: Python :: 3.9",
@@ -101,7 +100,7 @@
101100
namespace_packages=namespaces,
102101
install_requires=dependencies,
103102
extras_require=extras,
104-
python_requires=">=3.6",
103+
python_requires=">=3.7",
105104
scripts=["scripts/fixup_keywords.py"],
106105
include_package_data=True,
107106
zip_safe=False,

0 commit comments

Comments
 (0)