Skip to content

Commit 720b39e

Browse files
authored
Q1 2024 Release (#830)
* 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
1 parent 3000f18 commit 720b39e

File tree

1,893 files changed

+3102
-213890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,893 files changed

+3102
-213890
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.coverage

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
* 23.0.0
2+
- Remove support for Python 3.7
3+
- Add support for Python 3.11 and 3.12
4+
- Remove support for Google Ads API v13
5+
- Add Docker support for unit tests
6+
- Switch to a native/implicit namespace package
7+
- Remove usage of pkg_resources
8+
19
* 22.1.0
210
- Google Ads API v15 release.
311
- Add configuration option allowing developer token to be ignored.

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
ARG image_name=ubuntu:20.04
2+
FROM ${image_name}
3+
4+
ARG DEBIAN_FRONTEND=noninteractive
5+
ENV TZ=Etc/GMT
6+
COPY . /google-ads-python
7+
RUN apt-get update -qy && \
8+
apt-get install -qy --no-install-recommends \
9+
ca-certificates \
10+
curl \
11+
gnupg2 && \
12+
. /etc/os-release && \
13+
echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu ${UBUNTU_CODENAME} main" > /etc/apt/sources.list.d/deadsnakes.list && \
14+
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F23C5A6CF475977595C89F51BA6932366A755776 && \
15+
apt-get update -qy && \
16+
apt-get install -qy --no-install-recommends \
17+
git \
18+
openssh-client \
19+
python3.8 \
20+
python3.8-distutils \
21+
python3.9 \
22+
python3.10 \
23+
python3.11 \
24+
python3.12 && \
25+
curl -fsSo /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
26+
python3.8 /tmp/get-pip.py && \
27+
python3.8 -m pip install --no-cache-dir --upgrade pip && \
28+
python3.9 /tmp/get-pip.py && \
29+
python3.9 -m pip install --no-cache-dir --upgrade pip && \
30+
python3.10 /tmp/get-pip.py && \
31+
python3.10 -m pip install --no-cache-dir --upgrade pip && \
32+
python3.11 /tmp/get-pip.py && \
33+
python3.11 -m pip install --no-cache-dir --upgrade pip && \
34+
python3.12 /tmp/get-pip.py && \
35+
python3.12 -m pip install --no-cache-dir --upgrade pip && \
36+
rm /tmp/get-pip.py && \
37+
python3 -m pip install --no-cache-dir "nox>=2020.12.31,<2022.6" && \
38+
rm -rf /var/cache/apt/lists
39+
40+
WORKDIR "/google-ads-python"

README.rst

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ Build Status
99

1010
Requirements
1111
------------
12-
* Python 3.7+
13-
14-
Note that Python 3.7 is deprecated in this package, and it will become fully
15-
incompatible in a future version. Please upgrade to Python 3.8 or higher to
16-
ensure you can continue using this package to access the Google Ads API.
12+
* Python 3.8+
1713

1814
Installation
1915
------------

examples/remarketing/add_flexible_rule_user_list.py

-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def main(client, customer_id):
104104
"http://example.com/example3"
105105
)
106106
user_list.membership_status = client.enums.UserListMembershipStatusEnum.OPEN
107-
user_list.membership_life_span = 365
108107
user_list.rule_based_user_list = rule_based_user_list_info
109108

110109
# Issue a mutate request to add the user list, then print the results.

google/__init__.py

-24
This file was deleted.

google/ads/__init__.py

-23
This file was deleted.

google/ads/googleads/__init__.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,4 @@
1919
import google.ads.googleads.errors
2020
import google.ads.googleads.util
2121

22-
VERSION = "22.1.0"
23-
24-
# Checks if the current runtime is Python 3.7.
25-
if sys.version_info.major == 3 and sys.version_info.minor <= 7:
26-
warnings.warn(
27-
"Python versions less than 3.7 are deprecated in the google-ads "
28-
"package. Please upgrade to Python 3.8 or higher.",
29-
category=DeprecationWarning,
30-
)
22+
VERSION = "23.0.0"

google/ads/googleads/client.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@
1313
# limitations under the License.
1414
"""A client and common configurations for the Google Ads API."""
1515

16-
from importlib import import_module
16+
from importlib import import_module, metadata
1717
import logging.config
18-
import pkg_resources
1918

2019
from google.api_core.gapic_v1.client_info import ClientInfo
2120
import grpc.experimental
22-
import proto
2321
from proto.enums import ProtoEnumMeta
2422

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

3432
_SERVICE_CLIENT_TEMPLATE = "{}Client"
3533

36-
_VALID_API_VERSIONS = ["v15", "v14", "v13"]
34+
_VALID_API_VERSIONS = ["v15", "v14"]
3735
_DEFAULT_VERSION = _VALID_API_VERSIONS[0]
3836

3937
# Retrieve the version of this client library to be sent in the user-agent
4038
# information of API calls.
41-
try:
42-
_CLIENT_INFO = ClientInfo(
43-
client_library_version=pkg_resources.get_distribution(
44-
"google-ads",
45-
).version,
46-
)
47-
except pkg_resources.DistributionNotFound:
48-
_CLIENT_INFO = ClientInfo()
39+
_CLIENT_INFO = ClientInfo(client_library_version=metadata.version("google-ads"))
4940

5041
# See options at grpc.github.io/grpc/core/group__grpc__arg__keys.html
5142
_GRPC_CHANNEL_OPTIONS = [

google/ads/googleads/config.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""A set of functions to help load configuration from various locations."""
1515

16-
from distutils.util import strtobool
1716
import functools
1817
import json
1918
import logging.config
@@ -414,18 +413,27 @@ def disambiguate_string_bool(value):
414413
A boolean.
415414
416415
Raises:
417-
TypeError: If the string is not a valid boolean representation.
416+
TypeError, ValueError: If the string is not a valid boolean
417+
representation.
418418
"""
419+
# This section reproduces the logic from the now deprecated
420+
# distutils.util.strtobool. The below values are the same used by strtobool
421+
# as true/false equivalents.
422+
true_equivalents = ("y", "yes", "t", "true", "on", "1")
423+
false_equivalents = ("n", "no", "f", "false", "off", "0")
424+
419425
if isinstance(value, bool):
420426
return value
421427
elif isinstance(value, str):
422-
try:
423-
return bool(strtobool(value))
424-
except ValueError:
428+
if value.lower() in true_equivalents:
429+
return True
430+
elif value.lower() in false_equivalents:
431+
return False
432+
else:
425433
raise ValueError(
426-
'The "use_proto_plus" configuration key value should be'
427-
f'explicitly set to "True" or "False" but "{value}" '
428-
"was given."
434+
"The 'use_proto_plus' configuration key value must be "
435+
f"explicitly set to {true_equivalents} for 'true', or "
436+
f"{false_equivalents} for 'false', but '{value}' was given."
429437
)
430438
else:
431439
raise TypeError(

google/ads/googleads/interceptors/metadata_interceptor.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@
1919
login-customer-id values.
2020
"""
2121

22-
import pkg_resources
22+
# TODO: Explicitly importing the protobuf package version here should be removed
23+
# once the below issue is resolved, and the protobuf version is added to the
24+
# request user-agent directly by the google-api-core package:
25+
# https://github.com/googleapis/python-api-core/issues/416
26+
from importlib import metadata
27+
28+
_PROTOBUF_VERSION = metadata.version("protobuf")
29+
2330

2431
from google.protobuf.internal import api_implementation
2532
from grpc import UnaryUnaryClientInterceptor, UnaryStreamClientInterceptor
2633

2734
from .interceptor import Interceptor
2835

29-
# TODO: This logic should be updated or removed once the following is fixed:
30-
# https://github.com/googleapis/python-api-core/issues/416
31-
try:
32-
_PROTOBUF_VERSION = pkg_resources.get_distribution("protobuf").version
33-
except pkg_resources.DistributionNotFound:
34-
# If the distribution can't be found for whatever reason then we set
35-
# the version to None so that we can know to leave this header out of the
36-
# request.
37-
_PROTOBUF_VERSION = None
38-
3936
# Determine which protobuf implementation is being used.
4037
if api_implementation.Type() == "cpp":
4138
_PB_IMPL_HEADER = "+c"

0 commit comments

Comments
 (0)