Does it work if you append '$' to the grep like so:"ls -1 /foo/lib/python33/site-packages | grep '#{req}$'"--Michael F. Weinberg | Director of Operationshttp://heavywaterops.com | @heavywateropsOn Fri, Mar 6, 2015 at 10:29 AM, Fabien Delpierre < " target="_blank"> > wrote:FabienThanks in advance!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:(foo)$$ source /foo/bin/activate$ pip listNote that it says "uninstalled" even though the package is definitely installed.One strange thing that might be relevant is that the Chef log reads something like the below line for each pip package: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.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.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
==> default: [2015-03-06T13:02:05-05:00] INFO: Upgrading python_pip[alembic==0.6.4] version from uninstalled to latest
pip (6.0.8)
setuptools (12.4)
virtualenv (12.0.7)
(foo)$ pip list
alembic (0.6.4)
...
pip (6.0.8)
...
setuptools (13.0.2)
...
==> default: [2015-03-06T13:01:57-05:00] INFO: Upgrading python_pip[gunicorn] version from 19.3.0 to latestFrankly 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.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.
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
Archive powered by MHonArc 2.6.16.