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

Provide ansible extra #948

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ To avail of fixes in an unreleased version, please download a ZIP file
Unreleased
----------

* :gh:issue:`947` Provide `ansible-core` extra which installs compatible version of ansible-core

v0.3.4 (2023-07-02)
-------------------

* :gh:issue:`929` Support Ansible 6 and ansible-core 2.13
* :gh:issue:`832` Fix runtime error when using the ansible.builtin.dnf module multiple times
* :gh:issue:`925` :class:`ansible_mitogen.connection.Connection` no longer tries to close the
* :gh:issue:`925` :class:`ansible_mitogen.connection.Connection` no longer tries to close the
connection on destruction. This is expected to reduce cases of `mitogen.core.Error: An attempt
was made to enqueue a message with a Broker that has already exitted`. However it may result in
resource leaks.
Expand Down
35 changes: 31 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,39 @@

from setuptools import find_packages, setup

def parse_assignment(line, starts_with):
if line.startswith(starts_with):
_, _, s = line.partition('=')
parts = ast.literal_eval(s.strip())
return parts
return None


def grep_version():
path = os.path.join(os.path.dirname(__file__), 'mitogen/__init__.py')
with open(path) as fp:
for line in fp:
if line.startswith('__version__'):
_, _, s = line.partition('=')
parts = ast.literal_eval(s.strip())
return '.'.join(str(part) for part in parts)
parts = parse_assignment(line, '__version__')
if parts:
return '.'.join(map(str, parts))


def ansible_core_version():
path = os.path.join(os.path.dirname(__file__), 'ansible_mitogen/loaders.py')
min_version = None
with open(path) as fp:
for line in fp:
ansible_version_min = parse_assignment(line, 'ANSIBLE_VERSION_MIN')
if ansible_version_min:
# ansible-core's minimum version is 2.11, older versions were
# called ansible-base.
if ansible_version_min == (2, 10):
ansible_version_min = (2, 11)
min_version = '.'.join(map(str, ansible_version_min))
ansible_version_max = parse_assignment(line, 'ANSIBLE_VERSION_MAX')
if ansible_version_max:
major, minor = ansible_version_max
return (min_version, '{}.{}'.format(major, minor + 1))


def long_description():
Expand Down Expand Up @@ -81,4 +105,7 @@ def long_description():
'Topic :: System :: Distributed Computing',
'Topic :: System :: Systems Administration',
],
extras_require = {
'ansible-core': ['ansible-core>={},<{}'.format(*ansible_core_version())],
},
)