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

pip with ensure => latest can spuriously skip the install #350

Open
mihelich opened this issue Dec 16, 2016 · 1 comment
Open

pip with ensure => latest can spuriously skip the install #350

mihelich opened this issue Dec 16, 2016 · 1 comment

Comments

@mihelich
Copy link

The pip resource checks whether the latest version is installed using essentially pip search pkg_name | grep -i INSTALLED.*latest. This can give false positives if you have one or more other related packages already installed, because pip search matches package names and descriptions. It doesn't seem to have an option for matching the package name exactly.

I observed this in practice when installing multiple Google API packages, for example:

  $pip_packages = [
    'google-cloud-core',
    'google-cloud-dataflow',
    'google-cloud-storage',
    'google-api-python-client',
  ]

  python::pip { $pip_packages:
    ensure       => latest,
    virtualenv   => $virtual_env_dir,
    owner        => $::user,
  }

And google-api-python-client spuriously matched a bunch of installed packages:

Debug: Executing with ...: 'pip search  google-api-python-client | grep -i INSTALLED | grep -i latest'
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 0.0.2 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 0.5.0 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 0.7.5 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 0.22.1 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 2.6.0 (latest)
Debug: /Stage[main]/Python::Pip[google-api-python-client]/Exec[pip_install_google-api-python-client]/unless:   INSTALLED: 1.6.0 (latest)
@7yl4r
Copy link

7yl4r commented May 15, 2017

possible fix would be to modify the grep? like this SO answer

Something like (untested):

pip search pkg_name | egrep "^.*pkg_name.*\(" | grep -i INSTALLED.*latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants