diff --git a/pythondp3/CMakeLists.txt b/pythondp3/CMakeLists.txt index b8c899a57b0fd24ce9c958bba3498959667c8322..75131590ccd74c9230f794d51a7a8f350bededef 100644 --- a/pythondp3/CMakeLists.txt +++ b/pythondp3/CMakeLists.txt @@ -1,11 +1,22 @@ # Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy) # SPDX-License-Identifier: GPL-3.0-or-later +# Create a pseudo install directory 'dp3' in the build directory that +# mimics the ${PYTHON_INSTALL_DIR}$ such that 'import dp3' can be used +# in the build environment +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dp3") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" + "${CMAKE_CURRENT_BINARY_DIR}/dp3/__init__.py" COPYONLY) + pybind11_add_module(pydp3 MODULE pydp3.cc) target_link_libraries(pydp3 PRIVATE LIBDP3) +# Output the library/module in the pseudo install directory 'dp3' +set_target_properties(pydp3 PROPERTIES LIBRARY_OUTPUT_DIRECTORY dp3) pybind11_add_module(parameterset MODULE parameterset.cc) target_link_libraries(parameterset PRIVATE LIBDP3) +# Output the library/module in the pseudo install directory 'dp3' +set_target_properties(parameterset PROPERTIES LIBRARY_OUTPUT_DIRECTORY dp3) install(TARGETS pydp3 parameterset DESTINATION "${PYTHON_INSTALL_DIR}/dp3") install(FILES __init__.py DESTINATION "${PYTHON_INSTALL_DIR}/dp3") diff --git a/pythondp3/test/integration/tImportDP3.py b/pythondp3/test/integration/tImportDP3.py index bd0a161bf1cab7fd21dd7e5916791892f0995be6..3f7f0d3d03742c30c1c2647bc91b6c98b9c96f48 100644 --- a/pythondp3/test/integration/tImportDP3.py +++ b/pythondp3/test/integration/tImportDP3.py @@ -20,10 +20,10 @@ Script can be invoked in two ways: """ -def test_import_pydp3(): +def test_import_dp3(): """ - Test import of pydp3 module + Test import of dp3 module One reason this might fail is when the linkage of this module, a shared library, is incomplete. In that case, the run-time linker will report unresolved symbols. """ - import pydp3 + import dp3 diff --git a/steps/test/integration/testInit.sh.in b/steps/test/integration/testInit.sh.in index 59ae5d6ce5eaea5f3b1f7209911d981315b3be10..0186a7bcb7d348b07c5574514c57212b962a0b58 100644 --- a/steps/test/integration/testInit.sh.in +++ b/steps/test/integration/testInit.sh.in @@ -4,6 +4,9 @@ # A test script should source this file at its start. # If this file is test_common.sh, CMake generated it from test_common.sh.in. +import sys +import os + # Set common environment for scripts. CMake configures these variables. srcdir=@CMAKE_CURRENT_SOURCE_DIR@ bindir=@CMAKE_BINARY_DIR@ @@ -12,6 +15,9 @@ dp3exe=@CMAKE_BINARY_DIR@/DP3 makesourcedbexe=@CMAKE_BINARY_DIR@/makesourcedb taqlexe=@TAQL_EXECUTABLE@ +# Prepend the search path with the python build dir, which contains the pseudo install directory 'dp3'. +sys.path.insert(0, os.path.join(bindir, "pythondp3")) + # Create and initialize temp directory # FIXME: can be removed once all integration tests are converted # to pytest diff --git a/steps/test/unit/mock/mockpystep.py b/steps/test/unit/mock/mockpystep.py index 574b5a696456b443a9d6577d6c15996fd9647015..b2aef1f372db5d9b95847033a2cfa77034ba951c 100644 --- a/steps/test/unit/mock/mockpystep.py +++ b/steps/test/unit/mock/mockpystep.py @@ -4,8 +4,8 @@ # MockPyStep.py: simple python step, where the MockPyStep inherits from # the (py)dp3.DPStep class. -import parameterset -from pydp3 import Step +from dp3 import parameterset +from dp3 import Step import numpy as np