recipes/apycot.setup.distutils.py
author David Douard <david.douard@logilab.fr>
Tue, 13 Jan 2015 14:19:00 +0100
changeset 1783 e3aad84adf03
parent 1760 db82548222eb
permissions -rw-r--r--
[pkg] prepare 4.0.0

# normally executed with following builtin variables:
# :prefix: where to install
# :wdir: working directory
# :test: the apyclotlib.atest.Test instance

import os
from os.path import join
from apycotlib import Command, SUCCESS

cmdargs = ['python', 'setup.py', 'install']
try:
    assert prefix is not None
    test.writer.info('Installing with prefix=%s' % prefix)
    # ensure environment variables are OK
    test.update_env(wdir, 'PATH',
                    os.pathsep.join((join(prefix, 'sbin'), join(wdir, 'sbin'),)),
                    os.pathsep)
    test.update_env(wdir, 'PYTHONPATH',
                    join(prefix, 'lib', 'python'),
                    os.pathsep)
    test.update_env(wdir, 'LD_LIBRARY_PATH',
                    join(prefix, 'lib'),
                    os.pathsep)
    cmdargs.extend(['--home', prefix])
except:
    test.writer.warning('No prefix given, hope you have set up a virtualenv...')

st = Command(test.writer, cmdargs, raises=True, cwd=wdir).run()
if st == SUCCESS:
    test.writer.info('Installation successfull')
else:
    test.writer.error('Installation failed (%s)'% st)