# 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)