Commit 2b367e8e authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

setting up pyxacc to auto-initialize internal library paths



Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent aa761a0e
......@@ -49,18 +49,19 @@ if(APPLE)
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif(APPLE)
add_library(pyxacc SHARED xacc-py.cpp)
add_library(_pyxacc SHARED xacc-py.cpp)
set_target_properties(pyxacc PROPERTIES PREFIX "")
set_target_properties(_pyxacc PROPERTIES PREFIX "")
target_link_libraries(pyxacc CppMicroServices xacc xacc-quantum-gate ${Boost_LIBRARIES} cpr curl)
target_link_libraries(_pyxacc CppMicroServices xacc xacc-quantum-gate ${Boost_LIBRARIES} cpr curl)
if(APPLE)
set_target_properties(pyxacc PROPERTIES INSTALL_RPATH "@loader_path/lib")
set_target_properties(pyxacc PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
set_target_properties(_pyxacc PROPERTIES INSTALL_RPATH "@loader_path/lib")
set_target_properties(_pyxacc PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
else()
set_target_properties(pyxacc PROPERTIES INSTALL_RPATH "$ORIGIN/lib")
set_target_properties(pyxacc PROPERTIES LINK_FLAGS "-shared")
set_target_properties(_pyxacc PROPERTIES INSTALL_RPATH "$ORIGIN/lib")
set_target_properties(_pyxacc PROPERTIES LINK_FLAGS "-shared")
endif()
install(TARGETS pyxacc DESTINATION ${CMAKE_INSTALL_PREFIX})
install(TARGETS _pyxacc DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES pyxacc.py DESTINATION ${CMAKE_INSTALL_PREFIX})
from _pyxacc import *
import os, platform
def initialize():
xaccHome = os.environ['HOME']+'/.xacc'
if not os.path.exists(xaccHome):
os.makedirs(xaccHome)
try:
file = open(xaccHome+'/.internal_plugins', 'r')
contents = file.read()
except IOError:
file = open(xaccHome+'/.internal_plugins', 'w')
contents = ''
file.close()
file = open(xaccHome+'/.internal_plugins', 'w')
xaccLocation = os.path.dirname(os.path.realpath(__file__))
if platform.system() == "Darwin":
libname1 = "libxacc-quantum-gate.dylib"
libname2 = "libxacc-quantum-aqc.dylib"
else:
libname1 = "libxacc-quantum-gate.so"
libname2 = "libxacc-quantum-aqc.so"
if xaccLocation+'/lib/'+libname1+'\n' not in contents:
file.write(xaccLocation+'/lib/'+libname1+'\n')
if xaccLocation+'/lib/'+libname2+'\n' not in contents:
file.write(xaccLocation+'/lib/'+libname2+'\n')
file.write(contents)
file.close()
initialize()
......@@ -29,7 +29,7 @@ namespace pybind11 { namespace detail {
};
}} // namespace pybind11::detail
PYBIND11_MODULE(pyxacc, m) {
PYBIND11_MODULE(_pyxacc, m) {
m.doc() = "Python bindings for XACC. XACC provides a plugin infrastructure for "
"programming, compiling, and executing quantum kernels in a language and "
"hardware agnostic manner.";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment