python2: remove ability to build python2 bindings from project
This removes Python 2 package generation from the project to encourage safer development with Python 3 instead. Documentation for the generated modules switched to Python 3. Default interpreter is now Python 3 but can be overridden if needed for running the tests only on older environments. Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
committed by
Propanu
parent
36696db591
commit
1a66c6dc6a
@@ -1,9 +1,6 @@
|
||||
set_source_files_properties (mraapython.i PROPERTIES CPLUSPLUS ON)
|
||||
set_source_files_properties (mraapython.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
|
||||
|
||||
if (PYTHON2_LIBRARY)
|
||||
add_subdirectory (python2)
|
||||
endif ()
|
||||
if (PYTHON3_LIBRARY)
|
||||
add_subdirectory (python3)
|
||||
endif ()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
* Copyright (c) 2016-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
@@ -30,27 +30,18 @@ mraa_python_isr(void (*isr)(void*), void* isr_args)
|
||||
syslog(LOG_ERR, "gpio: PyEval_CallObject failed");
|
||||
PyObject *pvalue, *ptype, *ptraceback;
|
||||
PyObject *pvalue_pystr, *ptype_pystr, *ptraceback_pystr;
|
||||
PyObject *pvalue_ustr, *ptype_ustr, *ptraceback_ustr;
|
||||
char *pvalue_cstr, *ptype_cstr, *ptraceback_cstr;
|
||||
PyErr_Fetch(&pvalue, &ptype, &ptraceback);
|
||||
pvalue_pystr = PyObject_Str(pvalue);
|
||||
ptype_pystr = PyObject_Str(ptype);
|
||||
ptraceback_pystr = PyObject_Str(ptraceback);
|
||||
// Python2
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
pvalue_cstr = PyString_AsString(pvalue_pystr);
|
||||
ptype_cstr = PyString_AsString(ptype_pystr);
|
||||
ptraceback_cstr = PyString_AsString(ptraceback_pystr);
|
||||
// Python 3 and up
|
||||
#elif PY_VERSION_HEX >= 0x03000000
|
||||
// In Python 3 we need one extra conversion
|
||||
PyObject *pvalue_ustr, *ptype_ustr, *ptraceback_ustr;
|
||||
pvalue_ustr = PyUnicode_AsUTF8String(pvalue_pystr);
|
||||
pvalue_cstr = PyBytes_AsString(pvalue_ustr);
|
||||
ptype_ustr = PyUnicode_AsUTF8String(ptype_pystr);
|
||||
ptype_cstr = PyBytes_AsString(ptype_ustr);
|
||||
ptraceback_ustr = PyUnicode_AsUTF8String(ptraceback_pystr);
|
||||
ptraceback_cstr = PyBytes_AsString(ptraceback_ustr);
|
||||
#endif // PY_VERSION_HEX
|
||||
syslog(LOG_ERR, "gpio: the error was %s:%s:%s", pvalue_cstr, ptype_cstr, ptraceback_cstr);
|
||||
Py_XDECREF(pvalue);
|
||||
Py_XDECREF(ptype);
|
||||
@@ -58,12 +49,9 @@ mraa_python_isr(void (*isr)(void*), void* isr_args)
|
||||
Py_XDECREF(pvalue_pystr);
|
||||
Py_XDECREF(ptype_pystr);
|
||||
Py_XDECREF(ptraceback_pystr);
|
||||
// Python 3 and up
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
Py_XDECREF(pvalue_ustr);
|
||||
Py_XDECREF(ptype_ustr);
|
||||
Py_XDECREF(ptraceback_ustr);
|
||||
#endif // PY_VERSION_HEX
|
||||
} else {
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
set_source_files_properties (mraa2.i PROPERTIES CPLUSPLUS ON)
|
||||
set_source_files_properties (mraa2.i PROPERTIES SWIG_FLAGS "-I${CMAKE_BINARY_DIR}/src")
|
||||
|
||||
message (STATUS "PYTHON2 attempting to build!")
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS "3.8")
|
||||
swig_add_module (python2-mraa python mraa2.i ../mraapy.c)
|
||||
else ()
|
||||
swig_add_library (python2-mraa LANGUAGE python SOURCES mraa2.i ../mraapy.c)
|
||||
endif ()
|
||||
swig_link_libraries (python2-mraa ${PYTHON2_LIBRARIES} mraa)
|
||||
|
||||
target_include_directories(${SWIG_MODULE_python2-mraa_REAL_NAME}
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../.."
|
||||
"${PYTHON2_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if (DOXYGEN_FOUND AND PYTHON2_EXECUTABLE)
|
||||
foreach (_file ${DOCCLASSES})
|
||||
add_dependencies (${SWIG_MODULE_python2-mraa_REAL_NAME} ${_file}class_doc_i)
|
||||
endforeach ()
|
||||
add_dependencies (${SWIG_MODULE_python2-mraa_REAL_NAME} common_hpp_doc_i)
|
||||
endif ()
|
||||
|
||||
set_target_properties (${SWIG_MODULE_python2-mraa_REAL_NAME} PROPERTIES
|
||||
OUTPUT_NAME _mraa
|
||||
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND} -DSWIGPYTHON2=${SWIG_FOUND}"
|
||||
)
|
||||
|
||||
install (TARGETS ${SWIG_MODULE_python2-mraa_REAL_NAME}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON2_PACKAGES_PATH}
|
||||
)
|
||||
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.py
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON2_PACKAGES_PATH}
|
||||
)
|
||||
|
||||
add_subdirectory (docs)
|
||||
@@ -1,15 +0,0 @@
|
||||
%module(docstring="Python interface to libmraa") mraa
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
#ifdef DOXYGEN
|
||||
%include common_hpp_doc.i
|
||||
%include gpio_class_doc.i
|
||||
%include i2c_class_doc.i
|
||||
%include pwm_class_doc.i
|
||||
%include aio_class_doc.i
|
||||
%include spi_class_doc.i
|
||||
%include uart_class_doc.i
|
||||
#endif
|
||||
|
||||
%include ../mraapython.i
|
||||
@@ -16,6 +16,13 @@ target_include_directories(${SWIG_MODULE_python3-mraa_REAL_NAME}
|
||||
"${PYTHON3_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
if (DOXYGEN_FOUND AND PYTHON3_EXECUTABLE)
|
||||
foreach (_file ${DOCCLASSES})
|
||||
add_dependencies (${SWIG_MODULE_python3-mraa_REAL_NAME} ${_file}class_doc_i)
|
||||
endforeach ()
|
||||
add_dependencies (${SWIG_MODULE_python3-mraa_REAL_NAME} common_hpp_doc_i)
|
||||
endif ()
|
||||
|
||||
set_target_properties (${SWIG_MODULE_python3-mraa_REAL_NAME} PROPERTIES
|
||||
OUTPUT_NAME _mraa
|
||||
COMPILE_FLAGS "${CMAKE_C_FLAGS} -DSWIGPYTHON=${SWIG_FOUND} -DSWIGPYTHON3=${SWIG_FOUND}"
|
||||
@@ -28,3 +35,5 @@ install (TARGETS ${SWIG_MODULE_python3-mraa_REAL_NAME}
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/mraa.py
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON3_PACKAGES_PATH}
|
||||
)
|
||||
|
||||
add_subdirectory (docs)
|
||||
|
||||
@@ -36,7 +36,7 @@ if (DOXYGEN_FOUND)
|
||||
COMMENT "Building HTML documentation with Sphinx"
|
||||
)
|
||||
|
||||
add_dependencies (sphinx ${SWIG_MODULE_python2-mraa_REAL_NAME})
|
||||
add_dependencies (sphinx ${SWIG_MODULE_python3-mraa_REAL_NAME})
|
||||
else ()
|
||||
message (SEND_ERROR "ERROR - Failed to find a compatible version of Sphinx. Python API doc will not be generated")
|
||||
endif (SPHINX_FOUND AND SPHINX_VERSION VERSION_GREATER "1.3")
|
||||
@@ -19,7 +19,7 @@ import os
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, "@CMAKE_BINARY_DIR@/src/python/python2")
|
||||
sys.path.insert(0, "@CMAKE_BINARY_DIR@/src/python/python3")
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user