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

Fix asyncio.run compatibility #459

Merged
merged 1 commit into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/459-asyncio.run-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Use compatibility code instead of trying to run ``asyncio.run`` directly, which will fail with Python 3.6 (https://github.com/ansible-community/antsibull/pull/459)."
15 changes: 8 additions & 7 deletions src/antsibull/build_ansible_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from antsibull_core import app_context
from antsibull_core.ansible_core import get_ansible_core_package_name, AnsibleCorePyPiClient
from antsibull_core.collections import install_separately, install_together
from antsibull_core.compat import asyncio_run
from antsibull_core.dependency_files import BuildFile, DependencyFileData, DepsFile
from antsibull_core.galaxy import CollectionDownloader, GalaxyClient
from antsibull_core.logging import log
Expand Down Expand Up @@ -403,7 +404,7 @@ def prepare_command() -> int:
new_clauses.append(f'<{min_version.major}.{min_version.minor + 1}.0')
deps[collection_name] = ','.join(new_clauses)

included_versions, new_ansible_core_version = asyncio.run(
included_versions, new_ansible_core_version = asyncio_run(
get_collection_and_core_versions(
deps, ansible_core_version_obj, app_ctx.galaxy_url,
ansible_core_allow_prerelease=_is_alpha(app_ctx.extra['ansible_version'])))
Expand Down Expand Up @@ -511,7 +512,7 @@ def rebuild_single_command() -> int:
os.mkdir(download_dir, mode=0o700)

# Download included collections
asyncio.run(download_collections(included_versions, app_ctx.galaxy_url,
asyncio_run(download_collections(included_versions, app_ctx.galaxy_url,
download_dir, app_ctx.collection_cache))

# Get Ansible changelog, add new release
Expand Down Expand Up @@ -549,7 +550,7 @@ def rebuild_single_command() -> int:
if os.path.isfile(path):
collections_to_install.append(path)

asyncio.run(install_together(collections_to_install, ansible_collections_dir))
asyncio_run(install_together(collections_to_install, ansible_collections_dir))

# Compose and write release notes to destination directory
release_notes = ReleaseNotes.build(changelog)
Expand Down Expand Up @@ -690,8 +691,8 @@ def build_multiple_command() -> int:
download_dir = os.path.join(tmp_dir, 'collections')
os.mkdir(download_dir, mode=0o700)

included_versions = asyncio.run(get_collection_versions(deps, app_ctx.galaxy_url))
asyncio.run(
included_versions = asyncio_run(get_collection_versions(deps, app_ctx.galaxy_url))
asyncio_run(
download_collections(included_versions, app_ctx.galaxy_url, download_dir,
app_ctx.collection_cache))
# TODO: PY3.8:
Expand All @@ -703,8 +704,8 @@ def build_multiple_command() -> int:
if os.path.isfile(path):
collections_to_install.append(path)

collection_dirs = asyncio.run(install_separately(collections_to_install, download_dir))
asyncio.run(make_collection_dists(app_ctx.extra['sdist_dir'], collection_dirs))
collection_dirs = asyncio_run(install_separately(collections_to_install, download_dir))
asyncio_run(make_collection_dists(app_ctx.extra['sdist_dir'], collection_dirs))

# Create the ansible package that deps on the collections we just wrote
package_dir = os.path.join(tmp_dir, f'ansible-{app_ctx.extra["ansible_version"]}')
Expand Down
3 changes: 2 additions & 1 deletion src/antsibull/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

from antsibull_core import app_context
from antsibull_core.ansible_core import get_ansible_core
from antsibull_core.compat import asyncio_run
from antsibull_core.dependency_files import DepsFile, DependencyFileData
from antsibull_core.galaxy import CollectionDownloader
from antsibull_core.yaml import load_yaml_bytes, load_yaml_file
Expand Down Expand Up @@ -494,7 +495,7 @@ def get_changelog(
CollectionChangelogCollector(collection, versions_per_collection[collection].values())
for collection in sorted(versions_per_collection.keys())
]
asyncio.run(collect_changelogs(collectors, core_collector, collection_cache))
asyncio_run(collect_changelogs(collectors, core_collector, collection_cache))

changelog = []

Expand Down
3 changes: 2 additions & 1 deletion src/antsibull/new_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from antsibull_core import app_context
from antsibull_core.ansible_core import AnsibleCorePyPiClient
from antsibull_core.compat import asyncio_run
from antsibull_core.dependency_files import BuildFile, parse_pieces_file
from antsibull_core.galaxy import GalaxyClient

Expand Down Expand Up @@ -90,7 +91,7 @@ def new_ansible_command():
app_ctx = app_context.app_ctx.get()
collections = parse_pieces_file(
os.path.join(app_ctx.extra['data_dir'], app_ctx.extra['pieces_file']))
dependencies = asyncio.run(get_version_info(collections, app_ctx.pypi_url))
dependencies = asyncio_run(get_version_info(collections, app_ctx.pypi_url))

ansible_core_release_infos = dependencies.pop('_ansible_core')
ansible_core_versions = [
Expand Down