-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
[BUG] salt.modules.pip:is_installed doesn't handle locally installed packages #58202
Comments
@jholloway7 how did you proceed? I'm currently a bit fed up with thousands of |
Sorry, this got lost in my github notifications or I would have replied sooner. I ended up using an 'unless' in my pip.installed state:
It uses the stdout of |
Conda support When pip is a part of Conda envirionment, pip freeze will return something like ``` argon2-cffi @ file:///tmp/build/80754af9/argon2-cffi_1613037097816/work async-generator @ file:///home/ktietz/src/ci/async_generator_1611927993394/work attrs @ file:///tmp/build/80754af9/attrs_1620827162558/work backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work bleach @ file:///tmp/build/80754af9/bleach_1628110601003/work boto3 @ file:///tmp/build/80754af9/boto3_1603939295338/work botocore @ file:///tmp/build/80754af9/botocore_1603924881626/work ... ``` And then salt will show parsing warnings like ``` [ERROR ] Can't parse line '_libgcc_mutex=0.1=main' [ERROR ] Can't parse line '_openmp_mutex=4.5=1_gnu' [ERROR ] Can't parse line 'abseil-cpp=20200923.3=h2531618_0' [ERROR ] Can't parse line 'appdirs=1.4.4=py_0' [ERROR ] Can't parse line 'argon2-cffi=20.1.0=py38h27cfd23_1' [ERROR ] Can't parse line 'arrow-cpp=1.0.1=py38h14434a2_32_cpu' [ERROR ] Can't parse line 'async_generator=1.10=pyhd3eb1b0_0' ``` What can be seen in saltstack#58202 The correct way to get package versions in that case is to use command like ``` /opt/conda/bin/conda list --export ``` which return something like ``` /opt/conda/bin/conda list --export # This file may be used to create an environment using: # $ conda create --name <env> --file <this file> # platform: linux-64 _libgcc_mutex=0.1=main _openmp_mutex=4.5=1_gnu abseil-cpp=20200923.3=h2531618_0 appdirs=1.4.4=py_0 argon2-cffi=20.1.0=py38h27cfd23_1 arrow-cpp=1.0.1=py38h14434a2_32_cpu ``` So I can use state like ``` pip-environment: pip.installed: - bin_env: /opt/conda/bin/pip3 - freeze_command: "/opt/conda/bin/conda list --export" - parallel: True - pkgs: ... - require: - conda: conda-environment ```
Description
I'm setting up a fairly complex virtualenv with a few packages (e.g. cdecimal-2.3, internal packages, etc) that aren't published on pypi for whatever reason. I copy the package into the file system, check the hash and pip install it from a local file.
The normal pip syntax for this is something like this:
But the same effect can be achieved through the
pip.installed
state:When you run
pip freeze --all
on this virtualenv, the output syntax of such packages is slightly different than the normal 'frozen' version number:This syntax isn't handled by the pip.is_installed module:
The pip.is_installed module is used by other pip states to determine if a given library is installed. Hence, while it doesn't fail any states, it never sees that the locally installed package has been installed and installs it every time.
Setup
Please note that this setup is contrived for simplicity with a readily accessible example. There are other ways to install this particular package using
--find-links
that works around the problem. For self-maintained dist packages, I haven't really found a good solution that's as straightforward as simply pip installing the dist tarball directly from the file system.Steps to Reproduce the behavior
Expected behavior
For completeness,
pip.is_installed
could/should parse thepip freeze
syntax of "[pkgname] @ file:///..." to determine that a locally installed package is present.I think it would be as simple as splitting on the first '@', trimming spaces and comparing the first element to the specified package name.
Screenshots
N/A
Versions Report
salt --versions-report
Additional context
N/A
The text was updated successfully, but these errors were encountered: