improved cython wrapper python3 support
parent
435762ca81
commit
5670c73158
|
@ -32,7 +32,7 @@
|
|||
find_package( PythonInterp )
|
||||
if ( PYTHONINTERP_FOUND )
|
||||
execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||
"import Cython; print Cython.__path__"
|
||||
"import Cython; print(Cython.__path__[0])"
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE CYTHON_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
|
@ -51,7 +51,7 @@ endif ()
|
|||
# RESULT=0 means ok
|
||||
if ( NOT RESULT )
|
||||
execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c"
|
||||
"import Cython; print Cython.__version__"
|
||||
"import Cython; print(Cython.__version__)"
|
||||
RESULT_VARIABLE RESULT
|
||||
OUTPUT_VARIABLE CYTHON_VAR_OUTPUT
|
||||
ERROR_VARIABLE CYTHON_VAR_OUTPUT
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
from gtsam import *
|
||||
from .gtsam import *
|
||||
${GTSAM_UNSTABLE_IMPORT}
|
||||
|
|
|
@ -394,6 +394,10 @@ void Module::emit_cython_pxd(FileWriter& pxdFile) const {
|
|||
|
||||
/* ************************************************************************* */
|
||||
void Module::emit_cython_pyx(FileWriter& pyxFile) const {
|
||||
// directives...
|
||||
// allow str to automatically coerce to std::string and back (for python3)
|
||||
pyxFile.oss << "# cython: c_string_type=str, c_string_encoding=ascii\n\n";
|
||||
|
||||
// headers...
|
||||
string pxdHeader = name;
|
||||
pyxFile.oss << "cimport numpy as np\n"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# cython: c_string_type=str, c_string_encoding=ascii
|
||||
|
||||
cimport numpy as np
|
||||
import numpy as npp
|
||||
cimport geometry
|
||||
|
|
Loading…
Reference in New Issue