mirror of
https://github.com/triqs/dft_tools
synced 2024-12-25 22:03:43 +01:00
Modification of triqs_prepare_local_pytriqs macro
With this modification it should now be possible to compile an application even if: 1) It has already been installed 2) One does not have write permissions on the installed dir modified: cmake/TRIQSConfig.cmake.in
This commit is contained in:
parent
28140f14fb
commit
5addd5412b
@ -118,6 +118,7 @@ endmacro()
|
|||||||
# A macro to create a local copy of triqs with the added python
|
# A macro to create a local copy of triqs with the added python
|
||||||
macro (triqs_prepare_local_pytriqs_merged_with_my_python python_destination)
|
macro (triqs_prepare_local_pytriqs_merged_with_my_python python_destination)
|
||||||
|
|
||||||
|
# Create the local build_pytriqs executable
|
||||||
file(WRITE ${CMAKE_BINARY_DIR}/build_pytriqs
|
file(WRITE ${CMAKE_BINARY_DIR}/build_pytriqs
|
||||||
"#!/bin/bash
|
"#!/bin/bash
|
||||||
export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH
|
export PYTHONPATH=${CMAKE_BINARY_DIR}:$PYTHONPATH
|
||||||
@ -125,17 +126,40 @@ ${TRIQS_PYTHON_INTERPRETER} $@"
|
|||||||
)
|
)
|
||||||
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_pytriqs)
|
execute_process(COMMAND chmod 755 ${CMAKE_BINARY_DIR}/build_pytriqs)
|
||||||
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}
|
# Get a list of all local py and pyx files
|
||||||
find . -type d -exec mkdir -p ${CMAKE_BINARY_DIR}/pytriqs/{} \;)
|
file(GLOB_RECURSE relative_local RELATIVE ${CMAKE_SOURCE_DIR}/python *.py *.pyx)
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}
|
foreach(f IN LISTS relative_local)
|
||||||
find . -type f -exec ln -snf ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}/{} ${CMAKE_BINARY_DIR}/pytriqs/{} \;)
|
string(REGEX REPLACE "pyx" "so" new_f ${f})
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E chdir ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}
|
list(APPEND local_files "${python_destination}/${new_f}")
|
||||||
find . -type l -exec ln -snf ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}/{} ${CMAKE_BINARY_DIR}/pytriqs/{} \;)
|
endforeach()
|
||||||
|
|
||||||
# Create directories where python files will go and make sure there is an __init__.py all the way
|
# Get a list of all installed python files and then
|
||||||
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/pytriqs/${python_destination})
|
# remove the local ones from that list
|
||||||
|
file(GLOB_RECURSE remote_files RELATIVE ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST} ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}/*)
|
||||||
|
foreach(f IN LISTS local_files)
|
||||||
|
list(REMOVE_ITEM remote_files ${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# Copy and install __init__.py files
|
# Get the remote directory structure, remove duplicates
|
||||||
|
foreach(f IN LISTS remote_files)
|
||||||
|
get_filename_component(d ${f} PATH)
|
||||||
|
list(APPEND remote_dirs "${d}")
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES remote_dirs)
|
||||||
|
list(REMOVE_ITEM remote_dirs "")
|
||||||
|
|
||||||
|
# Create locally the remote directory structure and add the python_destination
|
||||||
|
foreach(d IN LISTS remote_dirs)
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/pytriqs/${d})
|
||||||
|
endforeach()
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/pytriqs/${python_destination})
|
||||||
|
|
||||||
|
# Do all symbolic links for the files
|
||||||
|
foreach(f IN LISTS remote_files)
|
||||||
|
execute_process(COMMAND ln -snf ${TRIQS_PATH}/${TRIQS_PYTHON_LIB_DEST}/${f} ${CMAKE_BINARY_DIR}/pytriqs/${f})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Copy and install the __init__.py files
|
||||||
file(WRITE ${CMAKE_BINARY_DIR}/.python/__init__.py "__all__=[]")
|
file(WRITE ${CMAKE_BINARY_DIR}/.python/__init__.py "__all__=[]")
|
||||||
set(partial_dir ${python_destination})
|
set(partial_dir ${python_destination})
|
||||||
while(partial_dir MATCHES "/")
|
while(partial_dir MATCHES "/")
|
||||||
|
Loading…
Reference in New Issue
Block a user