From 4269a9f599871879988a730117e0787fc169c241 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Tue, 8 Oct 2024 21:07:45 +0200 Subject: [PATCH] Add basic Proxy support. --- changelogs/fragments/631-proxy-env.yml | 5 +++++ src/antsibull_build/announcements.py | 2 +- src/antsibull_build/build_ansible_commands.py | 4 ++-- src/antsibull_build/changelog.py | 2 +- src/antsibull_build/utils/galaxy.py | 2 +- src/antsibull_build/versions.py | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/631-proxy-env.yml diff --git a/changelogs/fragments/631-proxy-env.yml b/changelogs/fragments/631-proxy-env.yml new file mode 100644 index 00000000..db90c2b2 --- /dev/null +++ b/changelogs/fragments/631-proxy-env.yml @@ -0,0 +1,5 @@ +minor_changes: + - "Use Proxy configuration settings from the environment. Check out the + `aiohttp documentation on Proxy support `__ + for information on which environment variables are supported + (https://github.com/ansible-community/antsibull-build/pull/631)." diff --git a/src/antsibull_build/announcements.py b/src/antsibull_build/announcements.py index efd9365a..06da3f60 100644 --- a/src/antsibull_build/announcements.py +++ b/src/antsibull_build/announcements.py @@ -191,7 +191,7 @@ async def get_data( end_of_life: Whether this is the last release for this major release train """ - async with ClientSession() as aio_session: + async with ClientSession(trust_env=True) as aio_session: client = PyPIClient(aio_session) try: release = await client.get_release("ansible", ansible_version) diff --git a/src/antsibull_build/build_ansible_commands.py b/src/antsibull_build/build_ansible_commands.py index 2f53b4d1..42bb7f84 100644 --- a/src/antsibull_build/build_ansible_commands.py +++ b/src/antsibull_build/build_ansible_commands.py @@ -74,7 +74,7 @@ async def download_collections( collection_cache: str | None = None, ) -> dict[str, str]: requestors = {} - async with aiohttp.ClientSession() as aio_session: + async with aiohttp.ClientSession(trust_env=True) as aio_session: lib_ctx = app_context.lib_ctx.get() async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool: downloader = CollectionDownloader( @@ -96,7 +96,7 @@ async def _get_ansible_core_path( download_dir: StrPath, ansible_core_version: PypiVer | str ) -> Path: flog = mlog.fields(func="_get_ansible_core_path") - async with aiohttp.ClientSession() as aio_session: + async with aiohttp.ClientSession(trust_env=True) as aio_session: ansible_core_tarball = Path( await get_ansible_core( aio_session, str(ansible_core_version), str(download_dir) diff --git a/src/antsibull_build/changelog.py b/src/antsibull_build/changelog.py index c4b10fcc..efa6a006 100644 --- a/src/antsibull_build/changelog.py +++ b/src/antsibull_build/changelog.py @@ -358,7 +358,7 @@ async def collect_changelogs( ): lib_ctx = app_context.lib_ctx.get() with tempfile.TemporaryDirectory() as tmp_dir: - async with aiohttp.ClientSession() as aio_session: + async with aiohttp.ClientSession(trust_env=True) as aio_session: if galaxy_context is None: galaxy_context = await GalaxyContext.create(aio_session) async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool: diff --git a/src/antsibull_build/utils/galaxy.py b/src/antsibull_build/utils/galaxy.py index ca4dd8f3..77bfea22 100644 --- a/src/antsibull_build/utils/galaxy.py +++ b/src/antsibull_build/utils/galaxy.py @@ -15,5 +15,5 @@ async def create_galaxy_context() -> GalaxyContext: """ Create a Galaxy context. """ - async with aiohttp.ClientSession() as aio_session: + async with aiohttp.ClientSession(trust_env=True) as aio_session: return await GalaxyContext.create(aio_session) diff --git a/src/antsibull_build/versions.py b/src/antsibull_build/versions.py index e5263b6d..d3bd9315 100644 --- a/src/antsibull_build/versions.py +++ b/src/antsibull_build/versions.py @@ -175,7 +175,7 @@ async def get_version_info( requestors = {} lib_ctx = app_context.lib_ctx.get() async with ( - aiohttp.ClientSession() as aio_session, + aiohttp.ClientSession(trust_env=True) as aio_session, asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool, ): pypi_client = AnsibleCorePyPiClient(