diff --git a/python/SConscript b/python/SConscript index 1ece570..1b61d76 100644 --- a/python/SConscript +++ b/python/SConscript @@ -1,43 +1,52 @@ from __future__ import print_function -from os.path import abspath +import SCons + +from os.path import abspath, join from SCons.Script import Import, Depends, Split, Copy Import('main_env') # Pybind11 wrapper env_pybind = main_env.Clone(SHLIBPREFIX='') env_pybind.Tool(pybind11) pybind_sources = Split(""" tamaas_module.cpp wrap/core.cpp wrap/percolation.cpp wrap/surface.cpp wrap/model.cpp wrap/solvers.cpp wrap/test_features.cpp """) if main_env['CXX'] != 'icpc': pybind_sources += ["wrap/bem.cpp"] env_pybind.AppendUnique(CPPDEFINES="LEGACY_BEM") # Building the pybind library tamaas_wrap = env_pybind.SharedLibrary( target='tamaas/_tamaas', source=pybind_sources, LIBS=['Tamaas'], RPATH=[abspath('../src')] ) # For some reason link happens too early Import('libTamaas') Depends(tamaas_wrap, libTamaas) # Copying the __init__.py file with extra python classes copy_env = env_pybind.Clone( PRINT_CMD_LINE_FUNC=main_env['gen_print']("Copying", "red", main_env)) -copy_env.Command(Dir('tamaas'), Dir('#python/tamaas'), - [Delete('$TARGET'), Copy("$TARGET", "$SOURCE")]) +python_package_content = Glob('#python/tamaas/*') +targets = map(lambda x: join('tamaas', x.name), python_package_content) + +for target, source in zip(targets, python_package_content): + if type(source) is SCons.Node.FS.Dir: + copy_env.Command(target, source, + [Delete("$TARGET"), Copy("$TARGET", "$SOURCE")]) + else: + copy_env.Command(target, source, Copy("$TARGET", "$SOURCE"))