mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 19:20:22 -07:00
pipx: accept python version specs in parameter name
(#10031)
* pipx: accept python version specs in parameter "name" * pipx_info: adjustment for backward compatibility * remove unnecessary comprehension * remove f-str * no shebang for module utils * remove f-str * fix syntax error * fix pipx_info * rollback adjustments in existing tests * docs & test update * add debugging tasks to int test * integration test checks for version of packaging * move assertion to block * fix idempotency when using version specifier * add changelog frag * fix docs * dial down the version of tox used in tests To accommodate old Pythons * Update plugins/modules/pipx.py * Apply suggestions from code review * refactor/rename package requirements code * fix filename in BOTMETA * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/pipx.py Co-authored-by: Felix Fontein <felix@fontein.de> * pipx mod utils: create make_process_dict and deprecate make_process_list * pkg_req: make method private * make_process_dict is simpler and more specialized * ensure version specifiers are honored when state=install * fix insanity * pipx: reformat yaml blocks * pipx: doc wordsmithing --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
626ee3115d
commit
2b4cb6dabc
8 changed files with 302 additions and 64 deletions
|
@ -71,36 +71,51 @@ def pipx_runner(module, command, **kwargs):
|
|||
return runner
|
||||
|
||||
|
||||
def make_process_list(mod_helper, **kwargs):
|
||||
def process_list(rc, out, err):
|
||||
if not out:
|
||||
return []
|
||||
def _make_entry(venv_name, venv, include_injected, include_deps):
|
||||
entry = {
|
||||
'name': venv_name,
|
||||
'version': venv['metadata']['main_package']['package_version'],
|
||||
'pinned': venv['metadata']['main_package'].get('pinned'),
|
||||
}
|
||||
if include_injected:
|
||||
entry['injected'] = {k: v['package_version'] for k, v in venv['metadata']['injected_packages'].items()}
|
||||
if include_deps:
|
||||
entry['dependencies'] = list(venv['metadata']['main_package']['app_paths_of_dependencies'])
|
||||
return entry
|
||||
|
||||
results = []
|
||||
|
||||
def make_process_dict(include_injected, include_deps=False):
|
||||
def process_dict(rc, out, err):
|
||||
if not out:
|
||||
return {}
|
||||
|
||||
results = {}
|
||||
raw_data = json.loads(out)
|
||||
for venv_name, venv in raw_data['venvs'].items():
|
||||
results[venv_name] = _make_entry(venv_name, venv, include_injected, include_deps)
|
||||
|
||||
return results, raw_data
|
||||
|
||||
return process_dict
|
||||
|
||||
|
||||
def make_process_list(mod_helper, **kwargs):
|
||||
#
|
||||
# ATTENTION!
|
||||
#
|
||||
# The function `make_process_list()` is deprecated and will be removed in community.general 13.0.0
|
||||
#
|
||||
process_dict = make_process_dict(mod_helper, **kwargs)
|
||||
|
||||
def process_list(rc, out, err):
|
||||
res_dict, raw_data = process_dict(rc, out, err)
|
||||
|
||||
if kwargs.get("include_raw"):
|
||||
mod_helper.vars.raw_output = raw_data
|
||||
|
||||
if kwargs["name"]:
|
||||
if kwargs["name"] in raw_data['venvs']:
|
||||
data = {kwargs["name"]: raw_data['venvs'][kwargs["name"]]}
|
||||
else:
|
||||
data = {}
|
||||
else:
|
||||
data = raw_data['venvs']
|
||||
|
||||
for venv_name, venv in data.items():
|
||||
entry = {
|
||||
'name': venv_name,
|
||||
'version': venv['metadata']['main_package']['package_version'],
|
||||
'pinned': venv['metadata']['main_package'].get('pinned'),
|
||||
}
|
||||
if kwargs.get("include_injected"):
|
||||
entry['injected'] = {k: v['package_version'] for k, v in venv['metadata']['injected_packages'].items()}
|
||||
if kwargs.get("include_deps"):
|
||||
entry['dependencies'] = list(venv['metadata']['main_package']['app_paths_of_dependencies'])
|
||||
results.append(entry)
|
||||
|
||||
return results
|
||||
|
||||
return [
|
||||
entry
|
||||
for name, entry in res_dict.items()
|
||||
if name == kwargs.get("name")
|
||||
]
|
||||
return process_list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue