Skip to content

Commit

Permalink
fix(python): drop python 3.6 (#1447)
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Jul 5, 2022
1 parent f3f0bd6 commit 4f89b13
Show file tree
Hide file tree
Showing 14 changed files with 159 additions and 134 deletions.
2 changes: 1 addition & 1 deletion synthtool/gcp/common.py
Expand Up @@ -238,7 +238,7 @@ def py_library(self, **kwargs) -> Path:
if "default_python_version" not in kwargs:
kwargs["default_python_version"] = "3.8"
if "unit_test_python_versions" not in kwargs:
kwargs["unit_test_python_versions"] = ["3.6", "3.7", "3.8", "3.9", "3.10"]
kwargs["unit_test_python_versions"] = ["3.7", "3.8", "3.9", "3.10"]

if "system_test_python_versions" not in kwargs:
kwargs["system_test_python_versions"] = ["3.8"]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

103 changes: 103 additions & 0 deletions synthtool/gcp/templates/python_library/README.rst
@@ -0,0 +1,103 @@
Python Client for {{ metadata['repo']['name_pretty'] }} API
======================{% for i in range(metadata['repo']['name_pretty']|length) %}={% endfor %}

|{{ metadata['repo']['release_level'] }}| |pypi| |versions|

`{{ metadata['repo']['name_pretty'] }} API`_: {% if metadata['repo']['api_description'] %}{{metadata['repo']['api_description'] }}{% endif %}

- `Client Library Documentation`_
- `Product Documentation`_

.. |{{ 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
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
.. |pypi| image:: https://img.shields.io/pypi/v/{{ metadata['repo']['distribution_name'] }}.svg
:target: https://pypi.org/project/{{ metadata['repo']['distribution_name'] }}/
.. |versions| image:: https://img.shields.io/pypi/pyversions/{{ metadata['repo']['distribution_name'] }}.svg
:target: https://pypi.org/project/{{ metadata['repo']['distribution_name'] }}/
.. _{{ metadata['repo']['name_pretty'] }} API: {{ metadata['repo']['product_documentation'] }}
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/{{ metadata['repo']['api_shortname'] }}/latest
.. _Product Documentation: {{ metadata['repo']['product_documentation'] }}

Quick Start
-----------

In order to use this library, you first need to go through the following steps:

1. `Select or create a Cloud Platform project.`_
2. `Enable billing for your project.`_
3. `Enable the {{ metadata['repo']['name_pretty'] }} API.`_
4. `Setup Authentication.`_

.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
.. _Enable the {{ metadata['repo']['name_pretty'] }} API.: {{ metadata['repo']['product_documentation'] }}
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Installation
~~~~~~~~~~~~

Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.

With `virtualenv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/


Code samples and snippets
~~~~~~~~~~~~~~~~~~~~~~~~~

Code samples and snippets live in the `samples/` folder.


Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
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
Python.

Python >= 3.7

Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Python <= 3.6

If you are using an [end-of-life](https://devguide.python.org/devcycle/#end-of-life-branches)
version of Python, we recommend that you update as soon as possible to an actively supported version.


Mac/Linux
^^^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install {{ metadata['repo']['distribution_name'] }}
Windows
^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install {{ metadata['repo']['distribution_name'] }}
Next Steps
~~~~~~~~~~

- Read the `Client Library Documentation`_ for {{ metadata['repo']['name_pretty'] }} API
to see other available methods on the client.
- Read the `{{ metadata['repo']['name_pretty'] }} API Product documentation`_ to learn
more about the product and see How-to Guides.
- View this `README`_ to see the full list of Cloud
APIs that we cover.

.. _{{ metadata['repo']['name_pretty'] }} API Product documentation: {{ metadata['repo']['product_documentation'] }}
.. _README: https://github.com/googleapis/google-cloud-python/blob/main/README.rst
79 changes: 49 additions & 30 deletions synthtool/gcp/templates/python_library/noxfile.py.j2
Expand Up @@ -346,28 +346,11 @@ def docfx(session):
def prerelease_deps(session):
"""Run all tests with prerelease versions of dependencies installed."""

prerel_deps = [
"protobuf",
"googleapis-common-protos",
"google-auth",
"grpcio",
"grpcio-status",
"google-api-core",
"proto-plus",
# dependencies of google-auth
"cryptography",
"pyasn1",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--upgrade", dep)

# Remaining dependencies
other_deps = ["requests"]
session.install(*other_deps)

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
session.install(*UNIT_TEST_STANDARD_DEPENDENCIES)
session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES)
system_deps_all = SYSTEM_TEST_STANDARD_DEPENDENCIES + SYSTEM_TEST_EXTERNAL_DEPENDENCIES + SYSTEM_TEST_EXTRAS
session.install(*system_deps_all)

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

# Ignore leading whitespace and comment lines.
deps = [
constraints_deps = [
match.group(1)
for match in re.finditer(
r"^\s*(\S+)(?===\S+)", constraints_text, flags=re.MULTILINE
)
]

# Don't overwrite prerelease packages.
deps = [dep for dep in deps if dep not in prerel_deps]
# We use --no-deps to ensure that pre-release versions aren't overwritten
# by the version ranges in setup.py.
session.install(*deps)
session.install("--no-deps", "-e", ".[all]")
session.install(*constraints_deps)

if os.path.exists("samples/snippets/requirements.txt"):
session.install("-r", "samples/snippets/requirements.txt")

if os.path.exists("samples/snippets/requirements-test.txt"):
session.install("-r", "samples/snippets/requirements-test.txt")

prerel_deps = [
"protobuf",
# dependency of grpc
"six",
"googleapis-common-protos",
"grpcio",
"grpcio-status",
"google-api-core",
"proto-plus",
"google-cloud-testutils",
# dependencies of google-cloud-testutils"
"click",
]

for dep in prerel_deps:
session.install("--pre", "--no-deps", "--upgrade", dep)

# Remaining dependencies
other_deps = [
"requests",
"google-auth",
]
session.install(*other_deps)

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

session.run("py.test", "tests/unit")
session.run("py.test", "tests/system")
session.run("py.test", "samples/snippets")

system_test_path = os.path.join("tests", "system.py")
system_test_folder_path = os.path.join("tests", "system")

# Only run system tests if found.
if os.path.exists(system_test_path) or os.path.exists(system_test_folder_path):
session.run("py.test", "tests/system")

snippets_test_path = os.path.join("samples", "snippets")

# Only run samples tests if found.
if os.path.exists(snippets_test_path):
session.run("py.test", "samples/snippets")
Expand Up @@ -12,7 +12,7 @@ Install Dependencies
.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

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

.. code-block:: bash
Expand Down
@@ -1 +1 @@
google-cloud-aiplatform==1.15.0
google-cloud-aiplatform==1.15.0
Expand Up @@ -12,7 +12,7 @@ Install Dependencies
.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

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

.. code-block:: bash
Expand Down
2 changes: 1 addition & 1 deletion synthtool/gcp/templates/python_samples/noxfile.py.j2
Expand Up @@ -89,7 +89,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", "3.10"]
ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/python_library/setup.py
Expand Up @@ -88,7 +88,6 @@
"License :: OSI Approved :: Apache Software License",
"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",
Expand All @@ -101,7 +100,7 @@
namespace_packages=namespaces,
install_requires=dependencies,
extras_require=extras,
python_requires=">=3.6",
python_requires=">=3.7",
scripts=["scripts/fixup_keywords.py"],
include_package_data=True,
zip_safe=False,
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/python_library_w_version_py/setup.py
Expand Up @@ -88,7 +88,6 @@
"License :: OSI Approved :: Apache Software License",
"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",
Expand All @@ -101,7 +100,7 @@
namespace_packages=namespaces,
install_requires=dependencies,
extras_require=extras,
python_requires=">=3.6",
python_requires=">=3.7",
scripts=["scripts/fixup_keywords.py"],
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit 4f89b13

Please sign in to comment.