Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
ThirdParty-common
Commits
092d71c3
Commit
092d71c3
authored
Jul 04, 2017
by
Mark OLESEN
Browse files
COMP: improve support for non-system python locations (issue
#17
)
parent
4a6ab377
Changes
2
Hide whitespace changes
Inline
Side-by-side
etc/tools/ParaViewFunctions
View file @
092d71c3
...
...
@@ -27,6 +27,18 @@
# Description
# ParaView make/install helper functions
#
# Note
# Obtainining paths via 'python-config' is possible, but may not always
# resolve properly:
#
# python-config --includes
# >>
# -I/usr/include/python2.7 -I/usr/include/python2.7
#
# python-config --libs
# >>
# -lpython2.7 -lpthread -ldl -lutil -lm
#
#------------------------------------------------------------------------------
# Variables referenced by the functions. Initialization at the end of the file.
...
...
@@ -159,68 +171,91 @@ addMpiSupport()
#
addPythonSupport
()
{
if
[
"
${
withPYTHON
:
=
false
}
"
!=
true
]
if
[
"
${
withPYTHON
:
-
false
}
"
!=
true
]
then
return
fi
if
pythonBin
=
$(
which python 2>/dev/null
)
local
pythonBin pythonConfig pythonMajor
pythonBin
=
$(
which python 2>/dev/null
)
||
{
echo
"*** Error: python not found"
echo
"*** Deactivate python support by not using the -python "
echo
"*** option"
exit
1
}
if
[
-n
"
$PYTHON_LIBRARY
"
]
then
if
[
-n
"
$PYTHON_LIBRARY
"
]
then
# Check $PYTHON_LIBRARY if it has been set
if
[
!
-e
"
$PYTHON_LIBRARY
"
]
then
echo
"*** Error: libpython not found at location specified "
\
"by -pythnon-lib input: PYTHON_LIBRARY=
$PYTHON_LIBRARY
"
fi
else
# Try to get $PYTHON_LIBRARY from dynamically linked binary
PYTHON_LIBRARY
=
$(
ldd
$pythonBin
|
\
sed
-ne
'/libpython/s/.* => \(.*\) (.*/\1/p'
)
[
-e
"
$PYTHON_LIBRARY
"
]
||
{
echo
"*** Error: Unable to determine path to python library."
}
fi
# PYTHON_LIBRARY set:
[
-e
"
$PYTHON_LIBRARY
"
]
||
\
echo
"*** Error: libpython not found at location specified "
\
"by -python-lib : PYTHON_LIBRARY=
$PYTHON_LIBRARY
"
else
# Fallback: get PYTHON_LIBRARY from dynamically linked binary
PYTHON_LIBRARY
=
$(
ldd
$pythonBin
|
\
sed
-ne
'/libpython/s/^.* => \(.*\) (.*/\1/p'
)
[
-e
"
$PYTHON_LIBRARY
"
]
||
{
echo
" Please set the full path to the python library "
echo
" (including libpython) using the -python-lib option, "
echo
" or deactivate python support by not using the -python "
echo
" option"
exit
1
echo
"*** Error: Unable to determine path to python library."
}
pythonMajor
=
$(
echo
$PYTHON_LIBRARY
|
sed
's/.*libpython\(.*\)\.so.*/\1/'
)
pythonInclude
=
/usr/include/python
$pythonMajor
fi
# Note - we could also allow for a PYTHON_INCLUDE variable ...
[
-d
"
$pythonInclude
"
-a
-f
"
$pythonInclude
/Python.h"
]
||
{
echo
" No python headers found in
$pythonInclude
/"
echo
" Please install python headers or deactivate "
echo
" python support by not using the -python option"
exit
1
}
[
-e
"
$PYTHON_LIBRARY
"
]
||
{
echo
" Please set the full path to the python library "
echo
" (including libpython) using the -python-lib option, "
echo
" or deactivate python support by not using the -python "
echo
" option"
exit
1
}
# Guess major from library
pythonMajor
=
$(
echo
$PYTHON_LIBRARY
|
sed
's/.*libpython\(.*\)\.so.*/\1/'
)
if
[
-n
"
$PYTHON_INCLUDE
"
]
then
addCMakeVariable
"PARAVIEW_ENABLE_PYTHON=ON"
addCMakeVariable
"PYTHON_INCLUDE_DIRS=
$pythonInclude
"
addCMakeVariable
"PYTHON_LIBRARY=
$PYTHON_LIBRARY
"
# PYTHON_INCLUDE set:
[
-d
"
$PYTHON_INCLUDE
"
-a
-f
"
$PYTHON_INCLUDE
/Python.h"
]
||
\
echo
"*** Error: Python.h not found at location specified "
\
"by -python-include : PYTHON_INCLUDE=
$PYTHON_INCLUDE
"
echo
"----"
echo
"Python information:"
echo
" executable :
$pythonBin
"
echo
" version :
$pythonMajor
"
echo
" include path :
$pythonInclude
"
echo
" library :
$PYTHON_LIBRARY
"
elif
pythonConfig
=
$(
which python-config 2>/dev/null
)
then
# Guess from python-config
# parse '-I/usr/include/python2.7 -I/usr/include/python2.7'
# -> '/usr/include/python2.7'
PYTHON_INCLUDE
=
$(
python-config
--includes
|
sed
-ne
's/^-I\([^ ][^ ]*\).*$/\1/p'
)
unset
pythonBin pythonInclude pythonMajor
else
echo
"*** Error: python not found"
echo
"*** Deactivate python support by not using the -python "
echo
"*** option"
exit
1
# Fallback to system headers
PYTHON_INCLUDE
=
/usr/include/python
$pythonMajor
fi
[
-d
"
$PYTHON_INCLUDE
"
-a
-f
"
$PYTHON_INCLUDE
/Python.h"
]
||
{
echo
" No python headers found in
$PYTHON_INCLUDE
/"
echo
" Please install python headers or deactivate "
echo
" python support by not using the -python option"
exit
1
}
addCMakeVariable
"PARAVIEW_ENABLE_PYTHON=ON"
addCMakeVariable
"PYTHON_INCLUDE_DIRS=
$PYTHON_INCLUDE
"
addCMakeVariable
"PYTHON_LIBRARY=
$PYTHON_LIBRARY
"
echo
"----"
echo
"Python information:"
echo
" executable :
$pythonBin
"
echo
" version :
$pythonMajor
"
echo
" include path :
$PYTHON_INCLUDE
"
echo
" library :
$PYTHON_LIBRARY
"
}
...
...
makeParaView
View file @
092d71c3
...
...
@@ -78,6 +78,8 @@ options:
-mpi with mpi
-mpi=N with max 'N' mpi processes. N=0 for no upper-limit.
-python with python
-python-include DIR
location of python headers (current:
${
PYTHON_INCLUDE
:-
none
}
)
-python-lib PATH path to python library (current:
${
PYTHON_LIBRARY
:-
none
}
)
-cmake PATH with cmake from the path given
-qmake PATH with the Qt version corresponding to the qmake path given
...
...
@@ -233,6 +235,12 @@ do
-no-python
)
withPYTHON
=
false
;;
-python-include
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
withPYTHON
=
true
PYTHON_INCLUDE
=
"
${
2
%%/
}
"
shift
;;
-python-lib
)
[
"$#"
-ge
2
]
||
die
"'
$1
' option requires an argument"
withPYTHON
=
true
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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