Python pip Ignored Target Option

Posted by: thogan 4 years, 10 months ago

I spent the weekend doing some database surgery on my DJango / Mezzanine site. The cause was pip doing something unexpected when i used the --target option. Instead of installing the updated version of Mezzanine in the specified target location, it nuked my existing installation in a different location and installed the new Mezzanine package in that directory.

Notice that I title this "pip Ignored" and not "pip Ignores". Web searching yielded no reports of similar unfortunate experiences. I am not sure what happened at this point or why pip seems to ignore --target on my platform, so this may not be a pip problem. None the less, I most certainly specified --target /where/I/wanted/packages and instead had pip install them into /oh/god/no.

I was trying to install the latest version of Mezzanine in a separate package directory so that I could see what I was going to get into when upgrading my site. However the new packages were installed over the current Mezzanine install in my main Python packages directory. The result was that my Mezzanine 1.4.12 installation and dependencies were gone and there was no getting them back. I had a freeze file that listed the versions of everything that had been installed, but many of those versions were long gone from PyPi.

Unfortunately, my Mezzanine project and database did not work with the upgraded version. I created a new Mezzanine site and began copying pages, blog posts, categories, etc from my production database into new database. Thirty five tables later, after adding data for columns that did not exist in my production database, and after resetting a number of sequences, the site was working again. Everything is now up to the latest version of Mezzanine and on Python 3, almost. I also found out that the reCAPTCHA Python client seems to have died on the vine about four years ago, so my contact page is disabled for now. It looks like I will have to port/build a Python 3 reCAPTCHA client on myself, which admittedly is not that big of a task.

I would like to know why pip ignored the --target option and rescheduled my weekend for me. If I come up with details I will update this post. Otherwise the moral of the story is: You cannot beat a virtual machine for environment isolation. I was running my staging environment and production on the same system, which there is really no excuse for in this day and age. Needless to say, I have a separate VM for stage now!

Posted by: thogan