Skip to content
Snippets Groups Projects
Commit c85a1fb8 authored by Bas van der Tol's avatar Bas van der Tol
Browse files

AST-1046 Mimic python install dir at build time

parent 73f23fd4
Branches
Tags
1 merge request!805AST-1046 Mimic python install dir at build time
# 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")
......@@ -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
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment