Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q1 2024 Release #830

Merged
merged 8 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.coverage
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
* 23.0.0
- Remove support for Python 3.7
- Add support for Python 3.11 and 3.12
- 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
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:20.04
BenRKarl marked this conversation as resolved.
Show resolved Hide resolved

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"
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"
13 changes: 2 additions & 11 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 @@ -38,14 +36,7 @@

# 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"]
BenRKarl marked this conversation as resolved.
Show resolved Hide resolved
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 should be "
BenRKarl marked this conversation as resolved.
Show resolved Hide resolved
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
6 changes: 5 additions & 1 deletion google/ads/googleads/v13/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
BenRKarl marked this conversation as resolved.
Show resolved Hide resolved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,10 @@
import importlib
import sys

from google.ads.googleads.v13 import gapic_version as package_version

__version__ = package_version.__version__


if sys.version_info < (3, 7):
raise ImportError("This module requires Python 3.7 or later.")
Expand Down
2 changes: 1 addition & 1 deletion google/ads/googleads/v13/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# -*- coding: utf-8 -*-
#
# Copyright 2018 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
#
__version__ = "0.0.0"
2 changes: 1 addition & 1 deletion google/ads/googleads/v13/common/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion google/ads/googleads/v13/common/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
26 changes: 19 additions & 7 deletions google/ads/googleads/v13/common/types/ad_asset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,9 @@ class AdTextAsset(proto.Message):
"""

text: str = proto.Field(
proto.STRING, number=4, optional=True,
proto.STRING,
number=4,
optional=True,
)
pinned_field: served_asset_field_type.ServedAssetFieldTypeEnum.ServedAssetFieldType = proto.Field(
proto.ENUM,
Expand All @@ -74,7 +76,9 @@ class AdTextAsset(proto.Message):
enum=gage_asset_performance_label.AssetPerformanceLabelEnum.AssetPerformanceLabel,
)
policy_summary_info: asset_policy.AdAssetPolicySummary = proto.Field(
proto.MESSAGE, number=6, message=asset_policy.AdAssetPolicySummary,
proto.MESSAGE,
number=6,
message=asset_policy.AdAssetPolicySummary,
)


Expand All @@ -90,7 +94,9 @@ class AdImageAsset(proto.Message):
"""

asset: str = proto.Field(
proto.STRING, number=2, optional=True,
proto.STRING,
number=2,
optional=True,
)


Expand All @@ -106,7 +112,9 @@ class AdVideoAsset(proto.Message):
"""

asset: str = proto.Field(
proto.STRING, number=2, optional=True,
proto.STRING,
number=2,
optional=True,
)


Expand All @@ -122,7 +130,9 @@ class AdMediaBundleAsset(proto.Message):
"""

asset: str = proto.Field(
proto.STRING, number=2, optional=True,
proto.STRING,
number=2,
optional=True,
)


Expand All @@ -139,7 +149,9 @@ class AdDiscoveryCarouselCardAsset(proto.Message):
"""

asset: str = proto.Field(
proto.STRING, number=1, optional=True,
proto.STRING,
number=1,
optional=True,
)


Expand Down
Loading