Open Akasurde opened 4 years ago
@imjoseangel @bmillemathias Are you interested in working on this? Let me know.
cc @MorrisA @bcoca @d-little @flynn1973 @gforster @kairoaraujo @marvin-sinister @mator @molekuul @ramooncamacho @willthames @wtcross click here for bot help
https://github.com/ansible-collections/community.general/blob/main/plugins/modules/system/python_requirements_info.py#L124 should handle additional square brackets.
@imjoseangel @bmillemathias Are you interested in working on this? Let me know.
@Akasurde do you mean to help new contributors, don't you?
yes,
Hi,
I would like to it. Thanks @imjoseangel for letting me know.
@Antares1980 @aparedero
Be aware of the following here:
When requesting information about the [extra] syntax, you will need to match a new group.
In the example, you will have:
ansible[azure]>=2.8.0
pkg = 'ansible'
extras = '[azure]'
op = '>='
version = '2.8.0
if extras is not None:
you need to handle if the required packages are installed with pkg_resources.require(pkg + extras)
and handle the exceptions.
Note that it is important to manage not only DistributionNotFound but also UnknownExtra exceptions.
@Antares1980 Let's work together to guide you with the different tips.
Thank you!!
Thanks @imjoseangel your help today to understand all the context has been exceptional.
As you said. To control the new group to check there are 4 places to review:
pkg, op, version = match.groups()
should be changed to pkg, extra, op, version = match.groups()
. Regular expression will allow only one extra by line.Distribution.require(extras=())
methodThanks again!
hi @Akasurde @aparedero I have been taking a look at this (including the abandoned PR). The major problem I see is that it does not need to be a package name (e.g. dnspython[DOH]
- it actually requires requests
). There is no trivial way, as far as I can see, to determine whether the extras have been installed or not.
From @aparedero on Nov 05, 2019 10:23
SUMMARY
python_requirements_info
(previouslypython_requirements_facts
) are not parsing pip packages if stated withproject[extra]
(similar to commandpip install "project[extra]"
) + infoISSUE TYPE
COMPONENT NAME
python_requirements_info
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Linux Mint 19.1
Linux pc04 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
STEPS TO REPRODUCE
Add this task somewhere in your playbook. This task reads requirements.txt file from root folder and iterates over each line ensuring is installed. My first line in requirements.txt is ansible[azure], and that's where fails due to the module is not able to parse the extra packages.
About my loop, if there is a missing library, a mismatched version, or getting a "Failed to parse" message as follows I return this as error, avoiding the playbook continues.
The
requirements.txt
in root folderEXPECTED RESULTS
ACTUAL RESULTS
Copied from original issue: ansible/ansible#64435