Skip to content

Commit

Permalink
feat: add async rest option in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr committed Sep 24, 2024
1 parent bedbab8 commit 25c7c19
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions gapic/templates/setup.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ dependencies = [
{% endif %}
{% endfor %}
]
extras = {
"async_rest": [
"google-api-core[grpc] >= 2.20.0, < 3.0.0dev",
"google-auth[aiohttp] >= 2.35.0, <3.0.0dev"
],
}
url = "https://github.com/googleapis/google-cloud-python/tree/main/packages/{{ api.naming.warehouse_package_name }}"
package_root = os.path.abspath(os.path.dirname(__file__))
Expand Down
5 changes: 5 additions & 0 deletions gapic/templates/testing/_default_constraints.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% from '_pypi_packages.j2' import pypi_packages %}
# This constraints file is required for unit tests.
# List all library dependencies and extras in this file.
google-api-core
{% if rest_async_io_enabled %}
google-auth[aiohttp]==2.35.0
{% endif %}
proto-plus
protobuf
{% for package_tuple, package_info in pypi_packages.items() %}
Expand Down
7 changes: 7 additions & 0 deletions gapic/templates/testing/constraints-3.7.txt.j2
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121): Remove the following variable (and the condition later in this file) for async rest transport once support for it is GA. #}
{% set rest_async_io_enabled = api.all_library_settings[api.naming.proto_package].python_settings.experimental_features.rest_async_io_enabled %}
{% from '_pypi_packages.j2' import pypi_packages %}
# 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
{% if rest_async_io_enabled %}
google-api-core==2.20.0
google-auth[aiohttp]==2.35.0
{% else %}
google-api-core==1.34.1
google-auth==2.14.1
{% endif %}
proto-plus==1.22.3
protobuf==3.20.2
{% for package_tuple, package_info in pypi_packages.items() %}
Expand Down
4 changes: 0 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,6 @@ def showcase_w_rest_async(
ignore_path = test_directory / ignore_file
pytest_command.extend(["--ignore", str(ignore_path)])

# Note: google-auth is re-installed here with aiohttp option to override the version installed in constraints.
session.install('--no-cache-dir', '--force-reinstall', "google-auth[aiohttp]")
session.run(
*pytest_command,
env=env,
Expand Down Expand Up @@ -485,8 +483,6 @@ def showcase_unit_w_rest_async(
"""Run the generated unit tests with async rest transport against the Showcase library."""
with showcase_library(session, templates=templates, other_opts=other_opts, rest_async_io_enabled=True) as lib:
session.chdir(lib)
# Note: google-auth is re-installed here with aiohttp option to override the version installed in constraints.
session.install('--no-cache-dir', '--force-reinstall', "google-auth[aiohttp]")
run_showcase_unit_tests(session, rest_async_io_enabled=True)


Expand Down

0 comments on commit 25c7c19

Please sign in to comment.