mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 06:30:19 -07:00
[PR #10031/2b4cb6da backport][stable-10] pipx: accept python version specs in parameter name
(#10149)
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
* Update plugins/modules/pipx.py
* 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
---------
(cherry picked from commit 2b4cb6dabc
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
8c8e755369
commit
9d245287b2
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