| Easily install all Python versions under Linux and OSX using collective.buildout.pythonPosted on July 16, 2010 by Mikko OhtamaaFiled Under plone, python, technology, ubuntu Here are short instructions how to install all versions (2.4, 2.5, 2.6, 2.7 and 3.1) of Python interpreters on UNIX system. The instructions were tested on Ubuntu 10.04 Lucid Lynx Linux but should work on other systems as is. The installation is based of downloading, compiling and installing different Pythons and their libraries using buildout tool. A buildout configuration for doing this is maintained by a Plone community. This buildout is especially useful to get Python 2.4 properly running under the latest Ubuntu 10.04 Lucid Lynx. This is because Ubuntu repositories won’t ship with Python 2.4 packages anymore. The installation will also include static compilation of some very popular libraries. These are dependencies for other Python packages including, but not limited, to
Prerequisites
Running itsvn co http://svn.plone.org/svn/collective/buildout/python/ cd python python bootstrap.py bin/buildout Using itAll Pythons are under virtualenv installations. This means that you can activate one Python configuration for your shell once easily (python command will run under different Python versions). Activating Python 2.4 source python/python-2.4/bin/activate (python-2.4)moo@murskaamo:~/code$ python -V Python 2.4.6 Check that Python Imaging Library works python Python 2.4.6 (#1, Jul 16 2010, 10:31:46) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import PIL (No exceptions raised, Python Imaging Library works well).
Installing Python Imaging Library (PIL) under virtualenv or buildoutPosted on November 19, 2009 by Mikko OhtamaaFiled Under plone, python, technology I have greatly struggled to have PIL library support in isolated Python environments like virtualenv –no-site-packages. For example, when installing Satchmo shop under virtualenv:
Though it clearly is there, installed by easy_install PIL command: ls ../lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-x86_64.egg ArgImagePlugin.py ExifTags.py GimpGradientFile.pyc... Does anyone know if this problem is with PIL itself, eggified PIL or something else? In any case, there is an easy workaround: use system-wide PIL (sudo apt-get install python-imaging) and symlink PIL from your site-wide installation under the isolated Python environment: (satchmo-py25)mulli% pwd /srv/plone/mmaspecial/satchmo-py25/lib/python2.5/site-packages (satchmo-py25)mulli% ln -s /usr/lib/python2.4/PIL . That works for now, but I’d like to learn how to make virtualenv and buildout install PIL egg bullet-proof way.
Packing and copying Data.fs from production server for local developmentPosted on September 1, 2009 by Mikko OhtamaaFiled Under plone, technology These instructions help you to copy and transfer production server ZODB database (Data.fs) to your local computer for development and testing. This allows you to do the testing against the copy of real data and the production server Plone instance set up. See the original tip by cguardia. Data.fs is ZODB file storage for transactional database. Journal history takes quite a lot of disk space there. Packing, i.e. removing the journal history, usually reduces the size file considerably, making the file lighter for wire transfer. Depending on the database age the packed copy is less than 10% of the original size. These instructions apply for Ubuntu/Debian based Linux systems. Apply to your own system using the operating system best practices. We need ZODB Python package to work with the database. To use it, we’ll create virtualenv Python installation in /tmp. In virtualenv installation, installed Python packages do not pollute or break the system wide setup. Note that you might use easy-install-2.4 depending on the OS. The latest stable ZODB can be picked from PyPi listing. Plone 3.x default is ZODB 3.7.x, which is not available as Python egg, but you can use ZODB 3.8.x. sudo easy-install virtualenv Data.fs cannot be modified in-place. You must create a copy of it to work with it. Data.fs copy can be created from a running system without the fear of corrupting the database, since ZODB is append only database. cp /yoursite/var/filestorage/Data.fs /tmp/Data.fs.copy Then create the following script snippet /tmp/pack.py using your favorite terminal editor. import time
import ZODB.FileStorage
import ZODB.serialize
storage=ZODB.FileStorage.FileStorage('/tmp/Data.fs.copy')
storage.pack(time.time(),ZODB.serialize.referencesf)
And run it using virtualenv’ed Python setup with ZODB installed: /tmp/packer/bin/python /tmp/pack.py Lots of patience here… packing may take a while, but it’s still definitely faster than your Internet connection transfer rate. Verify that the file is succesfully packed: ls -lh Data.fs.copy -rw-r--r-- 1 user user 30M 2009-09-01 13:24 Data.fs.copy Woohoo 1 GB was shrunk to 30 MB. Then copy the file to your local computer using scp and place it to your development buildout. scp user@server:/tmp/Data.fs.copy ~/mybuildout/var/filestorage/Data.fs You just saved about 30-90 minutes of waiting of file transfer. Python code management & deployment – a glance at zc.buildout and few othersPosted on September 2, 2008 by Tuukka MustonenFiled Under development tools, django, python, zope We’ve been using zc.buildout for Plone deployment and it’s working out great. A few days ago implemented a buildout recipe for Django project deployment, automatic web configuration, symlinking, media-folder structuring etc. and while I got it working, I came up with twisted feelings. Buildout is from the creators of Zope (I suppose) so you can expect a powerful project code management tool. The question is, however, whether or not it suits your needs. In my case I found out it too heavy. I mean, to add even a simple task you have to create a new “recipe” (a package) that does the tricks. Of course some recipes are generic (found from PyPi) and you can just run them with your own INI options, but in my case I had to do some custom implementation. Creating a new python package isn’t that hard for sure I found out that zc.buildout has some nice features like:
The problems?
There’s no denying zc.buildout is powerful, but I wouldn’t use it for projects which need reasonable amount of customization. It’s just plain easier and quicker to write shell scripts and while those won’t provide you with any sort of ready tools you won’t propably need them. For bringing up somewhat static environment, where you don’t need to hack things (like that for Plone) it’s quite a decent option, however. I also explored alternatives to zc.buildout. I’ve been reading about earlier virtualenv but haven’t really tried it out until now. It looks very promising and creates a more flexible environment compared to zc.buildout. Of course their goals are not exactly the same. Also, there are a few other alternatives out there, among them a new Python code management tool called Paver (just look at that cool logo.. it does remind you of Indiana Jones, does it not?). I glanced through the Paver docs and it looks like it might be the way to go (Paver also supports virtualenv), but didn’t quite get the grasp of the benefits just yet. Anyway, if you are still interested in code management and deployment, I’d recommend you to read the Paver release announcement and also Paver forewords. They should clear things up. |
