-
Notifications
You must be signed in to change notification settings - Fork 69
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
feat: Add support for python 312 (ads templates) #1861
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends '_base.py.j2' %} | ||
{% block content %} | ||
|
||
__version__ = "0.0.0" | ||
{% endblock %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,55 +2,84 @@ | |
|
||
{% block content %} | ||
|
||
import os | ||
import re | ||
|
||
import setuptools # type: ignore | ||
|
||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
setuptools.setup( | ||
name='{{ api.naming.warehouse_package_name }}', | ||
version='0.0.1', | ||
{% if api.naming.namespace %} | ||
packages=setuptools.PEP420PackageFinder.find(), | ||
namespace_packages={{ api.naming.namespace_packages }}, | ||
{% else %} | ||
packages=setuptools.find_packages(), | ||
{% endif %} | ||
platforms='Posix; MacOS X; Windows', | ||
include_package_data=True, | ||
install_requires=( | ||
{# TODO(dovs): remove when 1.x deprecation is complete #} | ||
{% if 'rest' in opts.transport %} | ||
"google-api-core[grpc] >= 2.10.0, < 3.0.0dev", | ||
{% else %} | ||
"google-api-core[grpc] >= 1.28.0, < 3.0.0dev", | ||
{% endif %} | ||
"googleapis-common-protos >= 1.53.0", | ||
"grpcio >= 1.10.0", | ||
"proto-plus >= 1.19.4, <2.0.0dev", | ||
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", | ||
name = '{{ api.naming.warehouse_package_name }}' | ||
|
||
{% set warehouse_description = api.naming.warehouse_package_name.replace('-',' ')|title %} | ||
{% set package_path = api.naming.module_namespace|join('/') + "/" + api.naming.module_name + "/" + api.naming.version %} | ||
|
||
description = "{{ warehouse_description }} API client library" | ||
|
||
version = None | ||
|
||
with open(os.path.join(package_root, '{{ package_path }}/gapic_version.py')) as fp: | ||
version_candidates = re.findall(r"(?<=\")\d+.\d+.\d+(?=\")", fp.read()) | ||
assert (len(version_candidates) == 1) | ||
version = version_candidates[0] | ||
|
||
if version[0] == "0": | ||
release_status = "Development Status :: 4 - Beta" | ||
else: | ||
release_status = "Development Status :: 5 - Production/Stable" | ||
|
||
dependencies = [ | ||
"google-api-core[grpc] >= 2.10.0, < 3.0.0dev", | ||
"googleapis-common-protos >= 1.53.0", | ||
"grpcio >= 1.10.0", | ||
"proto-plus >= 1.19.4, <2.0.0dev", | ||
"proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", | ||
{% if api.requires_package(('google', 'iam', 'v1')) %} | ||
'grpc-google-iam-v1', | ||
"grpc-google-iam-v1", | ||
{% endif %} | ||
), | ||
python_requires='>=3.7',{# Lazy import requires module-level getattr #} | ||
] | ||
|
||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
packages = [ | ||
package | ||
for package in setuptools.find_namespace_packages() | ||
if package.startswith("{{ api.naming.namespace_packages|first }}") | ||
] | ||
|
||
setuptools.setup( | ||
name=name, | ||
version=version, | ||
description=description, | ||
author="Google LLC", | ||
author_email="googleapis-packages@google.com", | ||
license="Apache 2.0", | ||
setup_requires=[ | ||
'libcst >= 0.2.5', | ||
], | ||
scripts=[ | ||
'scripts/fixup_{{ api.naming.versioned_module_name }}_keywords.py', | ||
], | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'Intended Audience :: Developers', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python :: 3.7', | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
'Programming Language :: Python :: 3.12', | ||
'Topic :: Internet', | ||
'Topic :: Software Development :: Libraries :: Python Modules', | ||
release_status, | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: Apache Software License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Operating System :: OS Independent", | ||
"Topic :: Internet", | ||
], | ||
platforms="Posix; MacOS X; Windows", | ||
packages=packages, | ||
python_requires=">=3.7", | ||
install_requires=dependencies, | ||
include_package_data=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't use the generated setup.py file, so I'm not sure it makes sense to make these changes, and perhaps you could remove it from the templates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is still needed so that we can run tests for the ads templates. We'll need to maintain it as long as we support ads templates. |
||
zip_safe=False, | ||
) | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is grabbing the version that's defined in the above
gapic_version
file, is that correct?The implementation is actually to access the version of the Ads client library itself, see the logic here
If you look at go/ads-client-libs-user-agent-design you can see that we opted to use the
gccl
user agent k/v for our own logging purposes, which is why thegapic_version
keyword arg is used here instead of something else.Is it possible to retrieve the client library version without pkg_resources? If not, then we might need to add that logic in our interceptors before this change can be made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is correct. In google-cloud-python, we use release-please to update the version in
gapic_version.py
prior to releasing. As an example see googleapis/google-cloud-python#12010.We've moved away from this in GAPIC, and chose to populate
gapic_version.py
instead of a hardcoded version number in setup.py. Customers can obtain the version number programatically using__version__
.It is possible to use something else like https://docs.python.org/3/library/importlib.metadata.html but we chose to have a version module instead.