Skip to content
Snippets Groups Projects
Commit 7ec82bdd authored by Marcel Loose's avatar Marcel Loose :sunglasses:
Browse files

Bug 1310: Fixed Python issues -- i.e. MWImager Python test scripts that

couldn't find the right Python modules -- with quite some duck-taping. This
solution doesn't win the "Beautiful Code Contest", but is solves the problems,
at least temporarily. Need to think of a more permanent solution, though.
parent d1ee47bc
No related branches found
No related tags found
No related merge requests found
# $Id$
lofar_package(MWImager 0.1 DEPENDS Common MWCommon)
lofar_package(MWImager 0.1 DEPENDS Common MWCommon pyparameterset)
lofar_find_package(Casacore COMPONENTS images REQUIRED)
......
......@@ -29,12 +29,6 @@
pgmpath=`dirname $0`
pgmpath=`cd $pgmpath > /dev/null 2>&1 && pwd`
# Check if LOFARROOT is set.
if test "$LOFARROOT" = ""; then
echo "LOFARROOT is undefined; source lofarinit.(c)sh first"
exit 1
fi
# Handle possible options.
imager=cimager
casaopt=none
......
......@@ -72,9 +72,9 @@ if test -d "$vds" -a -e "$vds/table.dat"; then
fi
if test "$img" = "casa"; then
$pgmpath/mwimager-casa $psn $seqnr $msn $vds $dry
$pgmpath/mwimager-casa $psn $seqnr $msn $vds $dry 2>/dev/null || exit 1
else
$pgmpath/mwimager-askap $psn $seqnr $msn $vds $dry
$pgmpath/mwimager-askap $psn $seqnr $msn $vds $dry 2>/dev/null || exit 1
fi
# Convert to FITS.
......
......@@ -2,6 +2,25 @@
include(LofarCTest)
# Create symbolic links to scripts used by the tmakems test program.
get_target_property(_loc getparsetvalue LOCATION)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_loc}
${CMAKE_CURRENT_BINARY_DIR}/getparsetvalue)
get_target_property(_loc finddproc LOCATION)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${_loc}
${CMAKE_CURRENT_BINARY_DIR}/finddproc)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${MWCommon_SOURCE_DIR}/src/startdistproc
${CMAKE_CURRENT_BINARY_DIR}/startdistproc)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${MWCommon_SOURCE_DIR}/src/socketrun
${CMAKE_CURRENT_BINARY_DIR}/socketrun)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_BINARY_DIR}/../src/convertimagerparset
${CMAKE_CURRENT_BINARY_DIR}/convertimagerparset)
lofar_add_test(tconvertimagerparset DEPENDS convertimagerparset)
lofar_add_test(tmwimager DEPENDS convertimagerparset)
lofar_add_test(tmwimager-dd DEPENDS convertimagerparset)
#lofar_add_test(tmwimager-dd DEPENDS convertimagerparset <AND MORE>)
......@@ -7,8 +7,8 @@
# PYTHON_FOUND - system has Python interpreter, Python headers
# files and libraries
# PYTHON_INCLUDE_DIRS - path to the Python header files
# PYTHON_INSTALL_DIR - installation directory for Python packages
# (cached)
# PYTHON_BUILD_DIR - build directory for Python packages (cached)
# PYTHON_INSTALL_DIR - installation directory for Python packages (cached)
# Copyright (C) 2009
# ASTRON (Netherlands Institute for Radio Astronomy)
......@@ -47,7 +47,7 @@ if(NOT DEFINED PYTHON_INSTALL_DIR)
if(PYTHON_EXECUTABLE)
set(_cmd
"from distutils.sysconfig import *"
"print get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}')")
"print get_python_lib(prefix='')")
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}"
OUTPUT_VARIABLE _pydir
......@@ -56,7 +56,9 @@ if(NOT DEFINED PYTHON_INSTALL_DIR)
if(_err)
message(FATAL_ERROR "Python command failed:\n${_err}")
endif(_err)
set(PYTHON_INSTALL_DIR "${_pydir}" CACHE PATH
set(PYTHON_BUILD_DIR "${CMAKE_BINARY_DIR}/${_pydir}" CACHE PATH
"Python site-packages build directory")
set(PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_pydir}" CACHE PATH
"Python site-packages installation directory")
endif(PYTHON_EXECUTABLE)
endif(NOT DEFINED PYTHON_INSTALL_DIR)
......
......@@ -146,7 +146,9 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED)
# --------------------------------------------------------------------------
macro(lofar_add_library _name)
add_library(${_name} ${ARGN})
set_property(GLOBAL APPEND PROPERTY ${PACKAGE_NAME}_LIBRARIES ${_name})
if(NOT "${ARGN}" MATCHES "^MODULE")
set_property(GLOBAL APPEND PROPERTY ${PACKAGE_NAME}_LIBRARIES ${_name})
endif(NOT "${ARGN}" MATCHES "^MODULE")
set(_link_libs)
foreach(_dep ${${PACKAGE_NAME}_DEPENDENCIES})
get_property(_dep_libs GLOBAL PROPERTY ${_dep}_LIBRARIES)
......
......@@ -50,16 +50,28 @@ macro(python_install)
endif(_dest_dir MATCHES "^$" OR _dest_dir MATCHES ";")
# Set python package install directory.
set(_dest_dir "${PYTHON_INSTALL_DIR}/${_dest_dir}")
set(_inst_dir "${PYTHON_INSTALL_DIR}/${_dest_dir}")
set(_build_dir "${PYTHON_BUILD_DIR}/${_dest_dir}")
# Make sure that there's a __init__.py file in each directory
string(REGEX REPLACE "/" ";" _dir_list ${_dest_dir})
set(_init_dir "${PYTHON_BUILD_DIR}")
foreach(_dir ${_dir_list})
set(_init_dir "${_init_dir}/${_dir}")
execute_process(COMMAND
${CMAKE_COMMAND} -E touch "${_init_dir}/__init__.py")
endforeach(_dir ${_dir_list})
# Install and byte-compile each Python file.
foreach(_py ${_py_files})
install(FILES ${_py} DESTINATION ${_dest_dir})
get_filename_component(_src_dir ${_py} ABSOLUTE)
configure_file(${_src_dir} ${_build_dir}/${_py} COPYONLY)
install(FILES ${_py} DESTINATION ${_inst_dir})
get_filename_component(_py ${_py} NAME)
set(_py_code
"import py_compile"
"print '-- Byte-compiling: ${_dest_dir}/${_py}'"
"py_compile.compile('${_dest_dir}/${_py}')")
"print '-- Byte-compiling: ${_inst_dir}/${_py}'"
"py_compile.compile('${_inst_dir}/${_py}')")
install(CODE
"execute_process(COMMAND ${PYTHON_EXECUTABLE} -c \"${_py_code}\")")
endforeach(_py ${_py_files})
......
......@@ -7,8 +7,10 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/include/${PACKAGE_NAME})
lofar_add_library(_pyparameterset SHARED pyparameterset.cc)
set_target_properties(_pyparameterset PROPERTIES PREFIX "")
lofar_add_library(_pyparameterset MODULE pyparameterset.cc)
set_target_properties(_pyparameterset PROPERTIES
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY ${PYTHON_BUILD_DIR}/lofar/parameterset)
# This is a quick-and-dirty fix to install the Python binding module in the
# right place. It will now be installed twice, because lofar_add_library()
......@@ -16,9 +18,10 @@ set_target_properties(_pyparameterset PROPERTIES PREFIX "")
install(TARGETS _pyparameterset
DESTINATION ${PYTHON_INSTALL_DIR}/lofar/parameterset)
lofar_add_library(lofar_pyparameterset Package__Version.cc)
lofar_add_bin_program(versionpyparameterset
versionpyparameterset.cc
Package__Version.cc)
versionpyparameterset.cc)
# Install Python modules
include(PythonInstall)
......
......@@ -27,6 +27,12 @@ lofar_sharedir=@lofar_sharedir@; export lofar_sharedir
prefix=@prefix@; export prefix
srcdir=@srcdir@; export srcdir
# When using CMake, add the Python build directory to PYTHONPATH.
if ! echo "@PYTHON_BUILD_DIR@" | grep "[@]PYTHON_BUILD_DIR[@]" > /dev/null
then
PYTHONPATH=@PYTHON_BUILD_DIR@; export PYTHONPATH
fi
# Start autoconf_share/runtest.sh
$lofar_sharedir/runtest.sh "$@"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment