On Mon, 2011-01-24 at 11:52 -0500, Kamil Paral wrote:
> a) The destination directory of autoqa library depends on the
> python version used. We can't hardcode it. Maybe we can transfer the
> library source code and do 'python setup.py install'?
Even though James suggested taking another approach, in the meantime
I worked on this one and this is the result I currently have:
# copy autoqa library
logging.debug("Copying autoqa library")
import autoqa
srcdir = os.path.dirname(autoqa.__file__)
assert srcdir, "Can't find autoqa library on the server"
srcdir += '/' # trailing slash is important
site_pkgs = host.run('python -c \'import sys,re; print filter(lambda s:
re.match("/usr/lib/.*/site-packages$",s),sys.path)[0]\'').stdout
site_pkgs = site_pkgs.strip() # remove trailing newline
assert site_pkgs, "Can't find python site-packages directory on the
client"
destdir = site_pkgs + '/autoqa/'
host.run('rm -rf %(dir)s; mkdir -p %(dir)s' % {'dir': destdir})
host.send_file(srcdir, destdir)
Too hackish?
Hmm, I like python setup.py install better because it is better to hand
off work to code that knows where to find the python site-packages dir
using a more robust approach.