1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
Import('env')
Import('compile_targets')
from os.path import dirname, basename, join, isfile
from os import walk
from glob import iglob
compile_target_files = [str(x[0]) for x in compile_targets]
def getAllFiles(root_dir, python_only=False, recursive=True):
if recursive:
for root, dirnames, filenames in walk(root_dir):
for filename in filenames:
if not python_only or filename.endswith('.py'):
yield join(root, filename)
else:
for filename in iglob(join(root_dir,'*')):
if not isfile(filename):
continue
if not python_only or filename.endswith('.py'):
yield filename
def installFile(file_name, build_target='install'):
#Don't do compile targets
if file_name in compile_target_files:
return
#ignore pyc and pyo. We get them from the py build.
if file_name.endswith('.pyc') or file_name.endswith('.pyo'):
return
if basename(file_name).startswith('.'):
return
target = File(file_name)
if file_name.endswith('.py'):
compiled_name = file_name+'c'
result = env.Command(compiled_name, file_name, CompilePython('$TARGET', '$SOURCE'))
if GetOption("clean"):
env.Default(result)
Alias(build_target, env.Install(env['PREFIX']+dirname(file_name), result))
else:
Alias(build_target, env.Install(env['PREFIX']+dirname(file_name), target))
#Contrib
# for file_name in getAllFiles('contrib/ZSI-2.1-a1/ZSI'):
# installFile(file_name)
#
# installFile('contrib/ZSI-2.1-a1/Copyright')
#ProPKA
for file_name in getAllFiles('propka30/'):
installFile(file_name)
#Whole directories
for dir_name in ('dat/', 'doc/', 'examples/', 'jmol/', 'images/', 'ZSI/', '3dmol/'):
for file_name in getAllFiles(dir_name):
installFile(file_name)
#Compiled Targets
for target in compile_targets:
file_name = str(target[0])
if file_name.endswith('.py'):
compiled_name = file_name+'c'
result = env.Command(compiled_name, file_name, CompilePython('$TARGET', '$SOURCE'))
if GetOption("clean"):
env.Default(result)
Alias('install', env.Install(env['PREFIX']+dirname(file_name), result))
else:
Alias('install', env.Install(env['PREFIX']+dirname(file_name), target))
#PDB2PKA
for file_name in getAllFiles('pdb2pka/'):
installFile(file_name)
#Main Program
for dir_name in ('src/',
'extensions/'):
for file_name in getAllFiles(dir_name, python_only=True):
installFile(file_name)
Alias('install', env.Install(env['PREFIX'], 'pdb2pqr.py'))
Alias('install', env.Install(env['PREFIX'], 'pdb2pqr.cgi'))
Alias('install', env.InstallAs(env['PREFIX']+'/index.html', 'html/server.html'))
for file_name in ('AppService_client.py',
'AppService_services.py',
'AppService_services_types.py',
'AppService_types.py',
'AUTHORS',
'ChangeLog.md',
'COPYING',
'main.py',
'main_cgi.py',
'NEWS',
'pka.py',
'pdb2pqr.css',
'README.md'):
installFile(file_name)
Alias('install', env.Command(env['PREFIX']+'tmp', None,
[Mkdir('$TARGET'),
Chmod('$TARGET', 0o777)]))
#Testing stuff to test installed pdb2pqr
for dir_name in ('tests/',
'scons/',
'site_scons/'):
for file_name in getAllFiles(dir_name):
installFile(file_name, build_target='install-tests')
Alias('install-tests', env.Install(env['PREFIX']+'scons/', 'scons/scons.py'))
Alias('install-tests', env.Install(env['PREFIX']+'site_scons/', 'site_scons/site_init.py'))
installFile('SConstruct', build_target='install-tests')
Alias('install-tests', 'install')
#Depends('install', DEFAULT_TARGETS)
#Requires('install', DEFAULT_TARGETS)
|