Skip to content

Commit

Permalink
Python: upgraded to version to 3.12.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Apr 10, 2024
2 parents 2511941 + e8ab741 commit f60bc95
Show file tree
Hide file tree
Showing 33 changed files with 1,214 additions and 776 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.vscode
CMakeLists.txt.user
43 changes: 36 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.22)

# Make sure that we are using the compilers we support
# Note #1: indeed, if other compilers are installed on a developer's machine
Expand Down Expand Up @@ -277,13 +277,33 @@ set(QT_PLUGINS_DIR ${QT_DIR}/plugins)

get_target_property(QMAKE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)

set(QMAKE_COMMAND ${QMAKE} -Wnone)
if(APPLE)
# Account for the fact that QMake (from Qt 5.12) doesn't work with Xcode 15
# Note: see https://bugreports.qt.io/browse/QTBUG-117225...

set(QMAKE_COMMAND ${QMAKE} -Wnone -early "QMAKE_DEFAULT_LIBDIRS=$(xcrun -show-sdk-path)/usr/lib")
else()
set(QMAKE_COMMAND ${QMAKE} -Wnone)
endif()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Find out, on Linux, whether we are using a RHEL-based distribution
# Note: this is needed for our Python bindings...

if(NOT WIN32 AND NOT APPLE)
cmake_host_system_information(RESULT DISTRIB_INFO QUERY DISTRIB_INFO)

set(RHEL_LINUX_DISTRIBS centos fedora rhel rocky)

if(DISTRIB_INFO_ID IN_LIST RHEL_LINUX_DISTRIBS)
set(RHEL_LINUX_DISTRIB ON)
endif()
endif()

# Determine our platform directory

if(WIN32)
Expand Down Expand Up @@ -1558,14 +1578,23 @@ else()
install(FILES ${MESA_LIBRARY}
DESTINATION lib)

# libtinfo.so.5 is needed by Qt, but is not present on vanilla Ubuntu
# 20.04/22.04 LTS while libffi.so.7 is needed by Python and is present on
# vanilla Ubuntu 20.04 LTS, but not on Ubuntu 22.04 LTS
# libtinfo is needed by Qt but is not present on either vanilla Ubuntu or
# RHEL-based distributions, while libffi.so is needed by Python and
# although it is present on vanilla Ubuntu, it isn't present on our other
# Linux distributions

if(RHEL_LINUX_DISTRIB)
set(LIBRARIES ffi.so.8 tinfo.so.5)
set(SYSTEM_LIBRARY_DIRECTORY /lib64)
else()
set(LIBRARIES ffi.so.7 tinfo.so.5)
set(SYSTEM_LIBRARY_DIRECTORY /lib/x86_64-linux-gnu)
endif()

foreach(LIBRARY ffi.so.7 tinfo.so.5)
foreach(LIBRARY ${LIBRARIES})
set(FULL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}${LIBRARY})

get_filename_component(REAL_FULL_LIBRARY /lib/x86_64-linux-gnu/${FULL_LIBRARY} REALPATH)
get_filename_component(REAL_FULL_LIBRARY ${SYSTEM_LIBRARY_DIRECTORY}/${FULL_LIBRARY} REALPATH)

install(FILES ${REAL_FULL_LIBRARY}
DESTINATION lib
Expand Down
1 change: 1 addition & 0 deletions distrib/linux/runipython
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
appDir="$(cd "$(dirname "$0")"; pwd)/../.."

export PATH="${appDir}/bin":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/python/bin/ipython" "$@"
1 change: 1 addition & 0 deletions distrib/linux/runjupyter
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
appDir="$(cd "$(dirname "$0")"; pwd)/../.."

export PATH="${appDir}/bin":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/python/bin/jupyter" "$@"
1 change: 1 addition & 0 deletions distrib/macos/runipython.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
appDir="$(cd "$(dirname "$0")"; pwd)/../../../../.."

export PATH="${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/MacOS":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python/bin/ipython" "$@"
1 change: 1 addition & 0 deletions distrib/macos/runjupyter.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
appDir="$(cd "$(dirname "$0")"; pwd)/../../../../.."

export PATH="${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/MacOS":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python/bin/jupyter" "$@"
1 change: 1 addition & 0 deletions distrib/windows/runipython.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TITLE Running the IPython environment...

SET AppDir=%~dp0..\..\
SET PYDEVD_DISABLE_FILE_VALIDATION=1

"%AppDir%Python\bin\Python.exe" "%AppDir%Python\Scripts\set_python_path.py" "%AppDir%Python" -s

Expand Down
1 change: 1 addition & 0 deletions distrib/windows/runjupyter.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TITLE Running the Jupyter environment...

SET AppDir=%~dp0..\..\
SET PYDEVD_DISABLE_FILE_VALIDATION=1

"%AppDir%Python\bin\Python.exe" "%AppDir%Python\Scripts\set_python_path.py" "%AppDir%Python" -s

Expand Down
16 changes: 14 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@ along with this program. If not, see <https://gnu.org/licenses>.
//==============================================================================

#if defined(PYTHON_SUPPORT) && defined(Q_OS_LINUX)
#ifdef _POSIX_SOURCE
#undef _POSIX_SOURCE
#endif

#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif

#ifdef _XOPEN_SOURCE
#undef _XOPEN_SOURCE
#endif

#include "Python.h"
// Note: this needs to be included before <QObject> to prevent name
// clashes...
#endif

//==============================================================================
Expand Down Expand Up @@ -73,7 +83,9 @@ int main(int pArgC, char *pArgV[])
// using dlopen() (see https://akkadia.org/drepper/dsohowto.pdf)...

#if defined(PYTHON_SUPPORT) && defined(Q_OS_LINUX)
#include "pythonbegin.h"
Py_NoUserSiteDirectory = 1;
#include "pythonend.h"
#endif

// Initialise Qt's message pattern
Expand Down
25 changes: 19 additions & 6 deletions src/plugins/dataStore/DataStore/src/datastorepythonwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ static PyMappingMethods DataStoreValuesDict_as_mapping = {

//==============================================================================

#include "pythonbegin.h"
static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDict)
{
// A string representation of a values dictionary
Expand Down Expand Up @@ -185,8 +184,10 @@ static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDic
PyObject *s;
int res;

#include "pythonbegin.h"
Py_INCREF(key);
Py_INCREF(value);
#include "pythonend.h"

if (!first) {
if (_PyUnicodeWriter_WriteASCIIString(&writer, ", ", 2) < 0) {
Expand All @@ -204,7 +205,9 @@ static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDic

res = _PyUnicodeWriter_WriteStr(&writer, s);

#include "pythonbegin.h"
Py_DECREF(s);
#include "pythonend.h"

if (res < 0) {
goto error; // NOLINT(cppcoreguidelines-avoid-goto, hicpp-avoid-goto)
Expand All @@ -219,7 +222,9 @@ static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDic
if (wrappedValue != nullptr) {
auto dataStoreValue = static_cast<DataStoreValue *>(wrappedValue->_objPointerCopy);

#include "pythonbegin.h"
Py_CLEAR(value);
#include "pythonend.h"

value = PyFloat_FromDouble(dataStoreValue->value());
}
Expand All @@ -232,14 +237,18 @@ static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDic

res = _PyUnicodeWriter_WriteStr(&writer, s);

#include "pythonbegin.h"
Py_DECREF(s);
#include "pythonend.h"

if (res < 0) {
goto error; // NOLINT(cppcoreguidelines-avoid-goto, hicpp-avoid-goto)
}

#include "pythonbegin.h"
Py_CLEAR(key);
Py_CLEAR(value);
#include "pythonend.h"
}

writer.overallocate = 0;
Expand All @@ -248,20 +257,22 @@ static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDic
goto error; // NOLINT(cppcoreguidelines-avoid-goto, hicpp-avoid-goto)
}

Py_ReprLeave((PyObject *)mp); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast, google-readability-casting)
Py_ReprLeave(reinterpret_cast<PyObject *>(mp));

return _PyUnicodeWriter_Finish(&writer);

error:
Py_ReprLeave((PyObject *)mp); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast, google-readability-casting)
Py_ReprLeave(reinterpret_cast<PyObject *>(mp));

_PyUnicodeWriter_Dealloc(&writer);

#include "pythonbegin.h"
Py_XDECREF(key);
Py_XDECREF(value);
#include "pythonend.h"

return nullptr;
}
#include "pythonend.h"

//==============================================================================
// Note: a DataStoreValuesDict is a dictionary sub-class for mapping between the
Expand All @@ -273,10 +284,10 @@ static PyTypeObject DataStoreValuesDict_Type = {
sizeof(DataStoreValuesDictObject), // tp_basicsize
0, // tp_itemsize
nullptr, // tp_dealloc
nullptr, // tp_print
0, // tp_vectorcall_offset
nullptr, // tp_getattr
nullptr, // tp_setattr
nullptr, // tp_compare
nullptr, // tp_as_async
reinterpret_cast<reprfunc>(DataStoreValuesDict_repr), // tp_repr
nullptr, // tp_as_number
nullptr, // tp_as_sequence
Expand Down Expand Up @@ -316,6 +327,8 @@ static PyTypeObject DataStoreValuesDict_Type = {
nullptr, // tp_del
0, // tp_version_tag
nullptr, // tp_finalize
nullptr, // tp_vectorcall
0, // tp_watched
};

//==============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ class OpenCORKernel(IPythonKernel):
if __name__ == '__main__':
from ipykernel.kernelapp import IPKernelApp
IPKernelApp.connection_file = '%3'
IPKernelApp.connection_file = r'%3'
IPKernelApp.launch_instance(kernel_class=OpenCORKernel)
)PYTHON";

PythonQtSupport::evaluateScript(JupyterKernel.arg(qApp->applicationName(),
qApp->applicationVersion(),
QString(pArguments[0]).replace("\\", "\\\\")));
pArguments[0]));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class QtConsole(object):
# still going to PythonQt (and the terminal shell), so we redirect
# logging output to the console
logging.getLogger().handlers[0].stream = sys.stderr
if logging.getLogger().hasHandlers():
logging.getLogger().handlers[0].stream = sys.stderr
def widget(self):
return self._widget
Expand Down
Loading

0 comments on commit f60bc95

Please sign in to comment.