diff --git a/buildconfig/CMake/CommonSetup.cmake b/buildconfig/CMake/CommonSetup.cmake index c6de3252f4bfb6af46f76753d0c759d76198247c..9a9787dc75a72c02762fced9936bb865db1a4c8a 100644 --- a/buildconfig/CMake/CommonSetup.cmake +++ b/buildconfig/CMake/CommonSetup.cmake @@ -22,13 +22,8 @@ set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin ) set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin ) if ( CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Xcode" ) set ( PVPLUGINS_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/plugins/paraview ) - # Location for built python modules - set ( PYTHON_MODULE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/lib/site-packages ) - set ( PYTHON_MODULE_OUTPUT_DIRECTORY_NO_GEN_EXPR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/lib/site-packages ) else () set ( PVPLUGINS_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins/paraview ) - set ( PYTHON_MODULE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib/site-packages ) - set ( PYTHON_MODULE_OUTPUT_DIRECTORY_NO_GEN_EXPR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib/site-packages ) endif() # This allows us to group targets logically in Visual Studio diff --git a/buildconfig/CMake/FindPyUnitTest.cmake b/buildconfig/CMake/FindPyUnitTest.cmake index df0bbad064c1bee2bf707182ba81bd92e280c1ff..9bfc279dca311adcce015b4edb2496a8d1a7179a 100644 --- a/buildconfig/CMake/FindPyUnitTest.cmake +++ b/buildconfig/CMake/FindPyUnitTest.cmake @@ -3,7 +3,8 @@ # Adds a set of python tests based upon the unittest module # Parameters: # _test_src_dir_base :: A base directory when added to the relative test paths gives -# an absolute path to that test +# an absolute path to that test. This directory is added to the +# PYTHONPATH when tests are executed # _testname_prefix :: A prefix for each test that is added to ctest, the name will be # ${_testname_prefix}_TestName # ${ARGN} :: List of test files @@ -22,11 +23,11 @@ function ( PYUNITTEST_ADD_TEST _test_src_dir _testname_prefix ) set ( _test_runner_module ${CMAKE_SOURCE_DIR}/Framework/PythonInterface/test/testhelpers/testrunner.py ) # Environment if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set ( _python_path ${PYTHON_XMLRUNNER_DIR};${PYTHON_MODULE_OUTPUT_DIRECTORY};$ENV{PYTHONPATH} ) + set ( _python_path ${PYTHON_XMLRUNNER_DIR};${_test_src_dir};$ENV{PYTHONPATH} ) # cmake list separator and Windows environment seprator are the same so escape the cmake one string ( REPLACE ";" "\\;" _python_path "${_python_path}" ) else() - set ( _python_path ${PYTHON_XMLRUNNER_DIR}:${PYTHON_MODULE_OUTPUT_DIRECTORY}:$ENV{PYTHONPATH} ) + set ( _python_path ${PYTHON_XMLRUNNER_DIR}:${_test_src_dir}:$ENV{PYTHONPATH} ) endif() # Add all of the individual tests so that they can be run in parallel diff --git a/buildconfig/CMake/PythonTargetFunctions.cmake b/buildconfig/CMake/PythonTargetFunctions.cmake deleted file mode 100644 index c7bfce05fc1c51ea9d866a332203637e3b82cfc9..0000000000000000000000000000000000000000 --- a/buildconfig/CMake/PythonTargetFunctions.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# Utility functions to add targets that "build" from pure python -# sources - -# Add rules to create a target that will copy and copy the -# given python sources to a given destination. The file names should -# be given relative to the current CMake sources list, e.g -# -# set ( SRCS -# mypkg/__init__.py -# ) -# add_python_package ( TARGET_NAME mypkg -# SRCS ${SRCS} -# OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin/mypkg -# ) -# -# will produce a directory in the specified location containing the listed -# files. -# -# Arguments: -# TARGET_NAME: The name of the target -# OUTPUT_DIR: The base directory for the copied and compiled files. Please -# note that this is used with add_custom_command so cannot -# contain generator expressions -# SRCS: A list of python source files for this package. The paths must be -# relative to the CMakeLists calling this function -# TEST_SRCS: A list of test files to include -function ( add_python_package ) - set ( options ) - set ( oneValueArgs TARGET_NAME OUTPUT_DIR ) - set ( multiValueArgs SRCS TEST_SRCS ) - cmake_parse_arguments ( PARSED "${options}" "${oneValueArgs}" - "${multiValueArgs}" ${ARGN} ) - - # Copy to build directory and compile - set ( _all_src ${PARSED_SRCS};${PARSED_TEST_SRCS} ) - set ( _pyc_files ) - foreach ( _it ${_all_src} ) - get_filename_component ( _directory ${_it} DIRECTORY ) - get_filename_component ( _filename_we ${_it} NAME_WE ) - set ( _pyc_out ${PARSED_OUTPUT_DIR}/${_directory}/${_filename_we}.pyc ) - list ( APPEND _pyc_files "${_pyc_out}" ) - add_custom_command ( - OUTPUT "${_pyc_out}" - # copy - COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - "${CMAKE_CURRENT_SOURCE_DIR}/${_it}" - "${PARSED_OUTPUT_DIR}/${_it}" - # compile - COMMAND ${PYTHON_EXECUTABLE} -m compileall -q - "${PARSED_OUTPUT_DIR}/${_it}" - - COMMENT "Compiling ${_it}" - DEPENDS - ${_it} - ) - endforeach() - - # Target - add_custom_target ( ${PARSED_TARGET_NAME} ALL - DEPENDS ${_pyc_files} - SOURCES ${_all_src} - ) - - # Tests - if ( PARSED_TEST_SRCS ) - pyunittest_add_test ( ${CMAKE_CURRENT_SOURCE_DIR} - ${PARSED_TARGET_NAME} ${PARSED_TEST_SRCS} ) - endif() -endfunction () diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 72126efb17423de1270ce6758919d8c0cae4c380..f32ea2d43b601759de7fee94d1e408599e404bc2 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -5,7 +5,6 @@ find_package ( QScintillaQt4 REQUIRED ) # Utilities for defining targets include ( QtTargetFunctions ) -include ( PythonTargetFunctions ) add_subdirectory ( widgets ) add_subdirectory ( python ) diff --git a/qt/python/CMakeLists.txt b/qt/python/CMakeLists.txt index 165c5b9a2f0ea33da244a118bcd33de366bbca30..d8ae39214d00fa852f081fc9e32e00a3e8bd99cf 100644 --- a/qt/python/CMakeLists.txt +++ b/qt/python/CMakeLists.txt @@ -5,20 +5,14 @@ # Legacy wrappers for MantidPlot add_subdirectory ( mantidqtpython ) -# All source files -set ( PYTHON_SOURCE_FILES - mantidqt/__init__.py -) - +# mantidqt is run from the source directory so just add tests set ( PYTHON_TEST_FILES mantidqt/test/import_test.py ) -# Target -add_python_package ( TARGET_NAME mantidqt - OUTPUT_DIR ${PYTHON_MODULE_OUTPUT_DIRECTORY_NO_GEN_EXPR} - SRCS ${PYTHON_SOURCE_FILES} - TEST_SRCS ${PYTHON_TEST_FILES} +# Tests +pyunittest_add_test ( ${CMAKE_CURRENT_SOURCE_DIR} + mantidqt ${PYTHON_TEST_FILES} ) -# Not installed yet... +# No package installation yet...