All of these things sound like bugs, you should file an issue.On Friday, March 6, 2015 at 10:29 AM, Fabien Delpierre wrote:
> Hello folks,
>
> I have the following bit of code:
>
> reqs.each do |req|
> python_pip req do
> virtualenv /foo
> action :upgrade
> not_if "ls -1 /foo/lib/python33/site-packages | grep #{req}"
> end
> end
>
> Now, reqs is a pretty large list of pip packages (probably about 30) compiled from a requirements file. Additionally, each package has a specific version requirement.
> So whenever Chef runs, it painstakingly attempts to upgrade every package listed in reqs despite my apparently feeble and incompetent not_if. It causes my Chef run to take 5-7 minutes instead of 2-3. This is fine for the first run, but this is a development VM for a team that iterates pretty fast, so 5-7 minute "compile times" are going to be a drag.
>
> One strange thing that might be relevant is that the Chef log reads something like the below line for each pip package:
>
> ==> default: [2015-03-06T13:02:05-05:00] INFO: Upgrading python_pip[alembic==0.6.4] version from uninstalled to latest
>
> Note that it says "uninstalled" even though the package is definitely installed.
> $ pip list
> pip (6.0.8)
> setuptools (12.4)
> virtualenv (12.0.7)
> $ source /foo/bin/activate
> (foo)$ pip list
> alembic (0.6.4)
> ...
> pip (6.0.8)
> ...
> setuptools (13.0.2)
> ...
> (foo)$
>
> Interestingly though, there is one package in reqs without a version requirement, it's gunicorn. When Chef tries to install it, it says this instead:
>
> ==> default: [2015-03-06T13:01:57-05:00] INFO: Upgrading python_pip[gunicorn] version from 19.3.0 to latest
>
> Frankly it shouldn't even be trying to install gunicorn anyway, but it's interesting/weird to me that for this one package, it accurately detects that it's installed and returns the installed version, whereas all the other ones report that they're uninstalled even though that's wrong.
>
> The ls command in my not_if returns the correct code whether the virtual environment is active or not.
>
> $ ls -1 /foo/lib/python3.3/site-packages | grep alem; echo $?
> alembic
> alembic-0.6.4-py3.3.egg-info
> 0
> $ ls -1 /foo/lib/python3.3/site-packages | grep foo; echo $?
> 1
>
> So unless I'm off the mark with my logic, the python_pip resource should execute only if grep returns 1... but that's not the case and I'm confused and help please pretty please with powdered sugar and a cherry on top.
Since you know the version you want, have you tried setting the version on the package resource and specifying `action :install` ? Including the desired version makes the install action behave like upgrade or downgrade if your existing version isn’t the desired one (modulo weirdness in the underlying packager’s implementation, for example rpm needs an extra flag to allow downgrades). It may be that the pip provider is just naive and doesn’t yet support this functionality, in which case that would be a separate bug to file.
>
> Thanks in advance!
> Fabien
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.