-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add __version__ in GAPIC clients (#1350)
* Chore: update setup.py to new standards * added end block * changed required python version * Edited golden files * Edited ads-templates setup.py * added missing commas to setup.py * changed classifiers for ads-template setup.py * changed ads-templates setup.py * Reverted ads-template changes * Added templeted version and updated protobuf * added package_root * Updated golden test files * Revert "added package_root" This reverts commit b8ce614. * Revert "Updated golden test files" This reverts commit ba37d13. * updated setup.py * Updated Golden files * added version to __init__.py * updated api-core dependency * updated setup.py to match golden * Changed version.py path to be set automatically * added version import into _base.py.j2 * changed version import placement * added changes from incremental-changes-setup-py * moved constraints file * updated golden files Co-authored-by: Anthonios Partheniou <[email protected]>
- Loading branch information
Showing
55 changed files
with
728 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends '_base.py.j2' %} | ||
{% block content %} | ||
|
||
__version__ = "0.1.0" | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,56 +4,86 @@ | |
|
||
import io | ||
import os | ||
import setuptools # type: ignore | ||
|
||
version = '0.1.0' | ||
import setuptools # type: ignore | ||
|
||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
readme_filename = os.path.join(package_root, 'README.rst') | ||
with io.open(readme_filename, encoding='utf-8') as readme_file: | ||
readme = readme_file.read() | ||
name = '{{ api.naming.warehouse_package_name }}' | ||
|
||
setuptools.setup( | ||
name='{{ api.naming.warehouse_package_name }}', | ||
author="Google LLC", | ||
author_email="[email protected]", | ||
url="https://github.com/googleapis/python-{{ api.naming.warehouse_package_name }}", | ||
version=version, | ||
long_description=readme, | ||
{% if api.naming.namespace %} | ||
packages=setuptools.PEP420PackageFinder.find(), | ||
namespace_packages={{ api.naming.namespace_packages }}, | ||
{% else %} | ||
packages=setuptools.PEP420PackageFinder.find(), | ||
{% endif %} | ||
platforms='Posix; MacOS X; Windows', | ||
include_package_data=True, | ||
install_requires=( | ||
'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', | ||
'libcst >= 0.2.5', | ||
'googleapis-common-protos >= 1.55.0, <2.0.0dev', | ||
'proto-plus >= 1.19.7', | ||
{% set warehouse_description = api.naming.warehouse_package_name.replace('-',' ')|title %} | ||
{% set package_path = api.naming.module_namespace|join('/') + "/" + api.naming.module_name %} | ||
|
||
description = "{{ warehouse_description }} API client library" | ||
|
||
version = {} | ||
with open(os.path.join(package_root, '{{ package_path }}/version.py')) as fp: | ||
exec(fp.read(), version) | ||
version = version["__version__"] | ||
|
||
if version[0] == "0": | ||
release_status = "Development Status :: 4 - Beta" | ||
else: | ||
release_status = "Development Status :: 5 - Production/Stable" | ||
|
||
dependencies = [ | ||
"google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", | ||
"proto-plus >= 1.22.0, <2.0.0dev", | ||
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", | ||
{# TODO: Remove after https://github.com/googleapis/gapic-generator-python/pull/1240 is merged. #} | ||
{% if api.requires_package(('google', 'iam', 'v1')) or opts.add_iam_methods or api.has_iam_mixin %} | ||
'grpc-google-iam-v1 >= 0.12.4, < 0.13dev', | ||
'grpc-google-iam-v1 >= 0.12.4, < 1.0.0dev', | ||
{% endif %} | ||
{% if api.requires_package(('google', 'cloud', 'documentai', 'v1')) %} | ||
'google-cloud-documentai >= 1.2.1, < 2.0.0dev', | ||
{% endif %} | ||
), | ||
python_requires='>=3.7', | ||
] | ||
url = "https://github.com/googleapis/python-{{ api.naming.warehouse_package_name|replace("google-cloud-", "") }}" | ||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
readme_filename = os.path.join(package_root, "README.rst") | ||
with io.open(readme_filename, encoding="utf-8") as readme_file: | ||
readme = readme_file.read() | ||
packages = [ | ||
package | ||
for package in setuptools.PEP420PackageFinder.find() | ||
if package.startswith("google") | ||
] | ||
namespaces = ["google"] | ||
if "google.cloud" in packages: | ||
namespaces.append("google.cloud") | ||
setuptools.setup( | ||
name=name, | ||
version=version, | ||
description=description, | ||
long_description=readme, | ||
author="Google LLC", | ||
author_email="[email protected]", | ||
license="Apache 2.0", | ||
url=url, | ||
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', | ||
'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", | ||
"Operating System :: OS Independent", | ||
"Topic :: Internet", | ||
], | ||
platforms="Posix; MacOS X; Windows", | ||
packages=packages, | ||
python_requires=">=3.7", | ||
namespace_packages=namespaces, | ||
install_requires=dependencies, | ||
include_package_data=True, | ||
zip_safe=False, | ||
) | ||
{% endblock %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This constraints file is required for unit tests. | ||
# List all library dependencies and extras in this file. | ||
google-api-core | ||
proto-plus | ||
protobuf | ||
{% if api.requires_package(('google', 'iam', 'v1')) or opts.add_iam_methods or api.has_iam_mixin %} | ||
grpc-google-iam-v1 | ||
{% endif %} | ||
{% if api.requires_package(('google', 'cloud', 'documentai', 'v1')) %} | ||
google-cloud-documentai | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
{% block constraints %} | ||
{% include "testing/_default_constraints.j2" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
{% block constraints %} | ||
{% include "testing/_default_constraints.j2" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This constraints file is used to check that lower bounds | ||
# are correct in setup.py | ||
# List all library dependencies and extras in this file. | ||
# Pin the version to the lower bound. | ||
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", | ||
# Then this file should have google-cloud-foo==1.14.0 | ||
# This file is intentionally left empty to test the | ||
# latest versions of dependencies. | ||
google-api-core==1.33.2 | ||
proto-plus==1.22.0 | ||
protobuf==3.19.5 | ||
{% if api.requires_package(('google', 'iam', 'v1')) or opts.add_iam_methods or api.has_iam_mixin %} | ||
grpc-google-iam-v1=0.12.4 | ||
{% endif %} | ||
{% if api.requires_package(('google', 'cloud', 'documentai', 'v1')) %} | ||
google-cloud-documentai=1.2.1 | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
{% block constraints %} | ||
{% include "testing/_default_constraints.j2" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
{% block constraints %} | ||
{% include "testing/_default_constraints.j2" %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/integration/goldens/asset/google/cloud/asset/version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2022 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 | ||
# | ||
# 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. | ||
# | ||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,45 +15,77 @@ | |
# | ||
import io | ||
import os | ||
import setuptools # type: ignore | ||
|
||
version = '0.1.0' | ||
import setuptools # type: ignore | ||
|
||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
readme_filename = os.path.join(package_root, 'README.rst') | ||
with io.open(readme_filename, encoding='utf-8') as readme_file: | ||
name = 'google-cloud-asset' | ||
|
||
|
||
description = "Google Cloud Asset API client library" | ||
|
||
version = {} | ||
with open(os.path.join(package_root, 'google/cloud/asset/version.py')) as fp: | ||
exec(fp.read(), version) | ||
version = version["__version__"] | ||
|
||
if version[0] == "0": | ||
release_status = "Development Status :: 4 - Beta" | ||
else: | ||
release_status = "Development Status :: 5 - Production/Stable" | ||
|
||
dependencies = [ | ||
"google-api-core[grpc] >= 1.33.2, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", | ||
"proto-plus >= 1.22.0, <2.0.0dev", | ||
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", | ||
'grpc-google-iam-v1 >= 0.12.4, < 1.0.0dev', | ||
] | ||
url = "https://github.com/googleapis/python-asset" | ||
|
||
package_root = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
readme_filename = os.path.join(package_root, "README.rst") | ||
with io.open(readme_filename, encoding="utf-8") as readme_file: | ||
readme = readme_file.read() | ||
|
||
packages = [ | ||
package | ||
for package in setuptools.PEP420PackageFinder.find() | ||
if package.startswith("google") | ||
] | ||
|
||
namespaces = ["google"] | ||
if "google.cloud" in packages: | ||
namespaces.append("google.cloud") | ||
|
||
setuptools.setup( | ||
name='google-cloud-asset', | ||
author="Google LLC", | ||
author_email="[email protected]", | ||
url="https://github.com/googleapis/python-google-cloud-asset", | ||
name=name, | ||
version=version, | ||
description=description, | ||
long_description=readme, | ||
packages=setuptools.PEP420PackageFinder.find(), | ||
namespace_packages=('google', 'google.cloud'), | ||
platforms='Posix; MacOS X; Windows', | ||
include_package_data=True, | ||
install_requires=( | ||
'google-api-core[grpc] >= 2.10.0, < 3.0.0dev', | ||
'libcst >= 0.2.5', | ||
'googleapis-common-protos >= 1.55.0, <2.0.0dev', | ||
'proto-plus >= 1.19.7', | ||
'grpc-google-iam-v1 >= 0.12.4, < 0.13dev', | ||
), | ||
python_requires='>=3.7', | ||
author="Google LLC", | ||
author_email="[email protected]", | ||
license="Apache 2.0", | ||
url=url, | ||
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', | ||
'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", | ||
"Operating System :: OS Independent", | ||
"Topic :: Internet", | ||
], | ||
platforms="Posix; MacOS X; Windows", | ||
packages=packages, | ||
python_requires=">=3.7", | ||
namespace_packages=namespaces, | ||
install_requires=dependencies, | ||
include_package_data=True, | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# This constraints file is required for unit tests. | ||
# List all library dependencies and extras in this file. | ||
google-api-core | ||
proto-plus | ||
protobuf | ||
grpc-google-iam-v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# This constraints file is required for unit tests. | ||
# List all library dependencies and extras in this file. | ||
google-api-core | ||
proto-plus | ||
protobuf | ||
grpc-google-iam-v1 |
12 changes: 12 additions & 0 deletions
12
tests/integration/goldens/asset/testing/constraints-3.7.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This constraints file is used to check that lower bounds | ||
# are correct in setup.py | ||
# List all library dependencies and extras in this file. | ||
# Pin the version to the lower bound. | ||
# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", | ||
# Then this file should have google-cloud-foo==1.14.0 | ||
# This file is intentionally left empty to test the | ||
# latest versions of dependencies. | ||
google-api-core==1.33.2 | ||
proto-plus==1.22.0 | ||
protobuf==3.19.5 | ||
grpc-google-iam-v1=0.12.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# This constraints file is required for unit tests. | ||
# List all library dependencies and extras in this file. | ||
google-api-core | ||
proto-plus | ||
protobuf | ||
grpc-google-iam-v1 |
Oops, something went wrong.