Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
6b58d4d8
Commit
6b58d4d8
authored
Sep 02, 2017
by
Mccaskey, Alex
Browse files
Adding plugin installation python script
parent
fdbfc910
Changes
2
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
6b58d4d8
...
...
@@ -102,3 +102,4 @@ install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/include/" DESTIN
install
(
DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/cppus_install/usr/local/lib/"
DESTINATION lib
)
install
(
DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/cppus_install/usr/local/share/"
DESTINATION share
)
install
(
DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/stage/usr/local/xacc/"
DESTINATION .
)
install
(
PROGRAMS
"
${
CMAKE_SOURCE_DIR
}
/tools/plugins/xacc-install-plugins.py"
DESTINATION bin
)
tools/plugins/xacc-install-plugins.py
0 → 100644
View file @
6b58d4d8
#!/usr/bin/env python
import
argparse
import
sys
import
os
import
subprocess
def
parse_args
(
args
):
parser
=
argparse
.
ArgumentParser
(
description
=
"XACC Plugin Installer."
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
,
fromfile_prefix_chars
=
'@'
)
parser
.
add_argument
(
"-p"
,
"--plugins"
,
nargs
=
'*'
,
type
=
str
,
help
=
"The XACC Plugins to install."
,
required
=
True
)
opts
=
parser
.
parse_args
(
args
)
return
opts
ornlqci
=
'https://github.com/ornl-qci'
availablePluginUrls
=
{
'xacc-scaffold'
:
ornlqci
+
'/xacc-scaffold'
,
'xacc-rigetti'
:
ornlqci
+
'/xacc-rigetti'
,
'xacc-dwave'
:
ornlqci
+
'/xacc-dwave'
,
'xacc-ibm'
:
ornlqci
+
'/xacc-ibm'
,
'xacc-python'
:
ornlqci
+
'/xacc-python'
,
'tnqvm'
:
ornlqci
+
'/tnqvm'
,
'ibm'
:
ornlqci
+
'/xacc-ibm'
,
'rigetti'
:
ornlqci
+
'/xacc-rigetti'
,
'scaffold'
:
ornlqci
+
'/xacc-scaffold'
,
'dwave'
:
ornlqci
+
'/xacc-dwave'
}
def
mkdir_p
(
path
):
""" Operates like mkdir -p in a Unix-like system """
try
:
os
.
makedirs
(
path
)
except
OSError
as
e
:
if
os
.
path
.
exists
(
path
)
and
os
.
path
.
isdir
(
path
):
pass
else
:
print
(
""
)
print
(
"--------------------------- ERROR -----------------------------"
)
print
(
"Cannot create directory "
+
path
)
print
(
"--------------------------- ERROR -----------------------------"
)
print
(
""
)
exit
()
def
main
(
argv
=
None
):
opts
=
parse_args
(
sys
.
argv
[
1
:])
# This python script should be in ${XACC_ROOT}/bin,
# we need to get XACC_ROOT
xaccLocation
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)))
# Get the plugins we're supposed to install
plugins
=
opts
.
plugins
# Loop over the plugins and install them
for
plugin
in
plugins
:
if
plugin
not
in
availablePluginUrls
:
print
(
""
)
print
(
"--------------------------- ERROR -----------------------------"
)
print
(
"Invalid plugin name - "
+
plugin
)
print
(
"--------------------------- ERROR -----------------------------"
)
print
(
""
)
exit
()
# Create a CMakeLists.txt file
cmakeContents
=
"""
project("""
+
plugin
+
"""-project LANGUAGES CXX)
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include(ExternalProject)
ExternalProject_Add("""
+
plugin
+
"""
GIT_REPOSITORY """
+
availablePluginUrls
[
plugin
]
+
"""
GIT_TAG master
CMAKE_ARGS -DXACC_DIR="""
+
xaccLocation
+
"""
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
TEST_BEFORE_INSTALL 1
)
"""
# Create a build directory
mkdir_p
(
plugin
+
'-install'
)
mkdir_p
(
plugin
+
'-install/build'
)
os
.
chdir
(
plugin
+
'-install'
)
# Write the CMakeLists file
cmakelists
=
open
(
"CMakeLists.txt"
,
"w"
)
cmakelists
.
write
(
"%s"
%
cmakeContents
)
cmakelists
.
close
()
# Execute the build
os
.
chdir
(
'build'
)
cmakecmd
=
[
'cmake'
,
'..'
]
subprocess
.
check_call
(
cmakecmd
,
stderr
=
subprocess
.
STDOUT
,
shell
=
False
)
subprocess
.
check_call
([
'make'
],
stderr
=
subprocess
.
STDOUT
,
shell
=
False
)
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment