Skip to content

Commit

Permalink
Q1 2024 Release (#830)
Browse files Browse the repository at this point in the history
* Add ability to run unit tests in a Docker container
* Remove support for Python 3.7
* Add support for Python 3.12
* Remove support for Google Ads API v13
* Move to implicit namespace, remove usage of pkg_resources
  • Loading branch information
BenRKarl authored Jan 23, 2024
1 parent 3000f18 commit 720b39e
Show file tree
Hide file tree
Showing 1,893 changed files with 3,102 additions and 213,890 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.coverage
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
* 23.0.0
- Remove support for Python 3.7
- Add support for Python 3.11 and 3.12
- Remove support for Google Ads API v13
- Add Docker support for unit tests
- Switch to a native/implicit namespace package
- Remove usage of pkg_resources

* 22.1.0
- Google Ads API v15 release.
- Add configuration option allowing developer token to be ignored.
Expand Down
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
ARG image_name=ubuntu:20.04
FROM ${image_name}

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Etc/GMT
COPY . /google-ads-python
RUN apt-get update -qy && \
apt-get install -qy --no-install-recommends \
ca-certificates \
curl \
gnupg2 && \
. /etc/os-release && \
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${UBUNTU_CODENAME} main" > /etc/apt/sources.list.d/deadsnakes.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776 && \
apt-get update -qy && \
apt-get install -qy --no-install-recommends \
git \
openssh-client \
python3.8 \
python3.8-distutils \
python3.9 \
python3.10 \
python3.11 \
python3.12 && \
curl -fsSo /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
python3.8 /tmp/get-pip.py && \
python3.8 -m pip install --no-cache-dir --upgrade pip && \
python3.9 /tmp/get-pip.py && \
python3.9 -m pip install --no-cache-dir --upgrade pip && \
python3.10 /tmp/get-pip.py && \
python3.10 -m pip install --no-cache-dir --upgrade pip && \
python3.11 /tmp/get-pip.py && \
python3.11 -m pip install --no-cache-dir --upgrade pip && \
python3.12 /tmp/get-pip.py && \
python3.12 -m pip install --no-cache-dir --upgrade pip && \
rm /tmp/get-pip.py && \
python3 -m pip install --no-cache-dir "nox>=2020.12.31,<2022.6" && \
rm -rf /var/cache/apt/lists

WORKDIR "/google-ads-python"
6 changes: 1 addition & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ Build Status

Requirements
------------
* Python 3.7+

Note that Python 3.7 is deprecated in this package, and it will become fully
incompatible in a future version. Please upgrade to Python 3.8 or higher to
ensure you can continue using this package to access the Google Ads API.
* Python 3.8+

Installation
------------
Expand Down
1 change: 0 additions & 1 deletion examples/remarketing/add_flexible_rule_user_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def main(client, customer_id):
"http://example.com/example3"
)
user_list.membership_status = client.enums.UserListMembershipStatusEnum.OPEN
user_list.membership_life_span = 365
user_list.rule_based_user_list = rule_based_user_list_info

# Issue a mutate request to add the user list, then print the results.
Expand Down
24 changes: 0 additions & 24 deletions google/__init__.py

This file was deleted.

23 changes: 0 additions & 23 deletions google/ads/__init__.py

This file was deleted.

10 changes: 1 addition & 9 deletions google/ads/googleads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,4 @@
import google.ads.googleads.errors
import google.ads.googleads.util

VERSION = "22.1.0"

# Checks if the current runtime is Python 3.7.
if sys.version_info.major == 3 and sys.version_info.minor <= 7:
warnings.warn(
"Python versions less than 3.7 are deprecated in the google-ads "
"package. Please upgrade to Python 3.8 or higher.",
category=DeprecationWarning,
)
VERSION = "23.0.0"
15 changes: 3 additions & 12 deletions google/ads/googleads/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
# limitations under the License.
"""A client and common configurations for the Google Ads API."""

from importlib import import_module
from importlib import import_module, metadata
import logging.config
import pkg_resources

from google.api_core.gapic_v1.client_info import ClientInfo
import grpc.experimental
import proto
from proto.enums import ProtoEnumMeta

from google.ads.googleads import config, oauth2, util
Expand All @@ -33,19 +31,12 @@

_SERVICE_CLIENT_TEMPLATE = "{}Client"

_VALID_API_VERSIONS = ["v15", "v14", "v13"]
_VALID_API_VERSIONS = ["v15", "v14"]
_DEFAULT_VERSION = _VALID_API_VERSIONS[0]

# Retrieve the version of this client library to be sent in the user-agent
# information of API calls.
try:
_CLIENT_INFO = ClientInfo(
client_library_version=pkg_resources.get_distribution(
"google-ads",
).version,
)
except pkg_resources.DistributionNotFound:
_CLIENT_INFO = ClientInfo()
_CLIENT_INFO = ClientInfo(client_library_version=metadata.version("google-ads"))

# See options at grpc.github.io/grpc/core/group__grpc__arg__keys.html
_GRPC_CHANNEL_OPTIONS = [
Expand Down
24 changes: 16 additions & 8 deletions google/ads/googleads/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""A set of functions to help load configuration from various locations."""

from distutils.util import strtobool
import functools
import json
import logging.config
Expand Down Expand Up @@ -414,18 +413,27 @@ def disambiguate_string_bool(value):
A boolean.
Raises:
TypeError: If the string is not a valid boolean representation.
TypeError, ValueError: If the string is not a valid boolean
representation.
"""
# This section reproduces the logic from the now deprecated
# distutils.util.strtobool. The below values are the same used by strtobool
# as true/false equivalents.
true_equivalents = ("y", "yes", "t", "true", "on", "1")
false_equivalents = ("n", "no", "f", "false", "off", "0")

if isinstance(value, bool):
return value
elif isinstance(value, str):
try:
return bool(strtobool(value))
except ValueError:
if value.lower() in true_equivalents:
return True
elif value.lower() in false_equivalents:
return False
else:
raise ValueError(
'The "use_proto_plus" configuration key value should be'
f'explicitly set to "True" or "False" but "{value}" '
"was given."
"The 'use_proto_plus' configuration key value must be "
f"explicitly set to {true_equivalents} for 'true', or "
f"{false_equivalents} for 'false', but '{value}' was given."
)
else:
raise TypeError(
Expand Down
19 changes: 8 additions & 11 deletions google/ads/googleads/interceptors/metadata_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@
login-customer-id values.
"""

import pkg_resources
# TODO: Explicitly importing the protobuf package version here should be removed
# once the below issue is resolved, and the protobuf version is added to the
# request user-agent directly by the google-api-core package:
# https://github.com/googleapis/python-api-core/issues/416
from importlib import metadata

_PROTOBUF_VERSION = metadata.version("protobuf")


from google.protobuf.internal import api_implementation
from grpc import UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor

from .interceptor import Interceptor

# TODO: This logic should be updated or removed once the following is fixed:
# https://github.com/googleapis/python-api-core/issues/416
try:
_PROTOBUF_VERSION = pkg_resources.get_distribution("protobuf").version
except pkg_resources.DistributionNotFound:
# If the distribution can't be found for whatever reason then we set
# the version to None so that we can know to leave this header out of the
# request.
_PROTOBUF_VERSION = None

# Determine which protobuf implementation is being used.
if api_implementation.Type() == "cpp":
_PB_IMPL_HEADER = "+c"
Expand Down
Loading

0 comments on commit 720b39e

Please sign in to comment.