Skip to content

Commit

Permalink
Python: added some scripts to run Python itself and pip.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny authored Aug 22, 2024
2 parents 5562b30 + 067fe4a commit 08c0c02
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 18 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,8 @@ if(WIN32)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . jupyterlab.vbs)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . jupyternotebook.bat)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . jupyternotebook.vbs)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . pip.bat)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . python.bat)

install(FILES ${PLATFORM_DISTRIB_DIR}/ipython.bat
${PLATFORM_DISTRIB_DIR}/jupyter.bat
Expand All @@ -1452,6 +1454,8 @@ if(WIN32)
${PLATFORM_DISTRIB_DIR}/jupyterlab.vbs
${PLATFORM_DISTRIB_DIR}/jupyternotebook.bat
${PLATFORM_DISTRIB_DIR}/jupyternotebook.vbs
${PLATFORM_DISTRIB_DIR}/pip.bat
${PLATFORM_DISTRIB_DIR}/python.bat
DESTINATION .)
endif()

Expand Down Expand Up @@ -1530,20 +1534,25 @@ elseif(APPLE)
set(JUPYTER_CONSOLE_FILENAME ${PROJECT_BUILD_DIR}/jupyterconsole)
set(JUPYTER_LAB_FILENAME ${PROJECT_BUILD_DIR}/jupyterlab)
set(JUPYTER_NOTEBOOK_FILENAME ${PROJECT_BUILD_DIR}/jupyternotebook)
set(PIP_FILENAME ${PROJECT_BUILD_DIR}/pip)
set(PYTHON_FILENAME ${PROJECT_BUILD_DIR}/python)
set(PYTHON_SHELL_FILENAME ${PROJECT_BUILD_DIR}/pythonshell)

configure_file(${PLATFORM_DISTRIB_DIR}/ipython.in ${IPYTHON_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/jupyter.in ${JUPYTER_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/jupyterconsole.in ${JUPYTER_CONSOLE_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/jupyterlab.in ${JUPYTER_LAB_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/jupyternotebook.in ${JUPYTER_NOTEBOOK_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/pip.in ${PIP_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/python.in ${PYTHON_FILENAME} @ONLY)
configure_file(${PLATFORM_DISTRIB_DIR}/pythonshell.in ${PYTHON_SHELL_FILENAME} @ONLY)

install(FILES ${IPYTHON_FILENAME}
${JUPYTER_FILENAME}
${JUPYTER_CONSOLE_FILENAME}
${JUPYTER_LAB_FILENAME}
${JUPYTER_NOTEBOOK_FILENAME}
${PYTHON_FILENAME}
${PYTHON_SHELL_FILENAME}
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
Expand Down Expand Up @@ -1637,13 +1646,16 @@ else()
configure_file(${PLATFORM_DISTRIB_DIR}/jupyterconsole.in ${JUPYTER_CONSOLE_FILENAME} @ONLY)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . jupyterlab)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . jupyternotebook)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . pip)
copy_file_to_build_dir(DIRECT ${PLATFORM_DISTRIB_DIR} . python)
configure_file(${PLATFORM_DISTRIB_DIR}/pythonshell.in ${PYTHON_SHELL_FILENAME} @ONLY)

install(FILES ${PLATFORM_DISTRIB_DIR}/ipython
${PLATFORM_DISTRIB_DIR}/jupyter
${JUPYTER_CONSOLE_FILENAME}
${PLATFORM_DISTRIB_DIR}/jupyterlab
${PLATFORM_DISTRIB_DIR}/jupyternotebook
${PLATFORM_DISTRIB_DIR}/python
${PYTHON_SHELL_FILENAME}
DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
Expand Down
2 changes: 1 addition & 1 deletion distrib/linux/ipython
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/python/bin/runipython" "$@"
"${appDir}/Python/bin/runipython" "$@"
2 changes: 1 addition & 1 deletion distrib/linux/jupyter
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/python/bin/runjupyter" "$@"
"${appDir}/Python/bin/runjupyter" "$@"
2 changes: 1 addition & 1 deletion distrib/linux/jupyterconsole.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/python/bin/runjupyter" console --kernel @CMAKE_PROJECT_NAME@ "$@"
"${appDir}/Python/bin/runjupyter" console --kernel @CMAKE_PROJECT_NAME@ "$@"
2 changes: 1 addition & 1 deletion distrib/linux/jupyterlab
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/python/bin/runjupyter" lab --ip 127.0.0.1 "$@"
"${appDir}/Python/bin/runjupyter" lab --ip 127.0.0.1 "$@"
2 changes: 1 addition & 1 deletion distrib/linux/jupyternotebook
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/python/bin/runjupyter" notebook --ip 127.0.0.1 "$@"
"${appDir}/Python/bin/runjupyter" notebook --ip 127.0.0.1 "$@"
7 changes: 7 additions & 0 deletions distrib/linux/pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/Python/bin/python" -m pip "$@"
7 changes: 7 additions & 0 deletions distrib/linux/python
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

appDir="$(cd "$(dirname "$0")"; pwd)"

export LD_LIBRARY_PATH="${appDir}/lib":$LD_LIBRARY_PATH

"${appDir}/Python/bin/python" "$@"
2 changes: 1 addition & 1 deletion distrib/linux/runipython
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)/../.."
export PATH="${appDir}/bin":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/python/bin/ipython" "$@"
"${appDir}/Python/bin/ipython" "$@"
2 changes: 1 addition & 1 deletion distrib/linux/runjupyter
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ appDir="$(cd "$(dirname "$0")"; pwd)/../.."
export PATH="${appDir}/bin":$PATH
export PYDEVD_DISABLE_FILE_VALIDATION=1

"${appDir}/python/bin/jupyter" "$@"
"${appDir}/Python/bin/jupyter" "$@"
3 changes: 3 additions & 0 deletions distrib/macos/pip.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

"$(cd "$(dirname "$0")"; pwd)/@[email protected]/Contents/Frameworks/Python/bin/python" -m pip "$@"
3 changes: 3 additions & 0 deletions distrib/macos/python.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

"$(cd "$(dirname "$0")"; pwd)/@[email protected]/Contents/Frameworks/Python/bin/python" "$@"
5 changes: 5 additions & 0 deletions distrib/windows/pip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF

TITLE Running Python...

CALL "%~dp0Python\bin\python.exe" -m pip %*
5 changes: 5 additions & 0 deletions distrib/windows/python.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF

TITLE Running Python...

CALL "%~dp0Python\bin\python.exe" %*
12 changes: 2 additions & 10 deletions src/plugins/support/PythonSupport/src/pythonsupportplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,15 @@ void PythonSupportPlugin::initializePlugin()

QString pythonHome = QCoreApplication::applicationDirPath()+"/../";

#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
pythonHome += "Python";
#elif defined(Q_OS_LINUX)
pythonHome += "python";
#else
pythonHome = pythonHome+"Frameworks/Python";
#endif

#if defined(Q_OS_WIN) || defined(Q_OS_LINUX)
if (!QDir(pythonHome).exists()) {
pythonHome = QCoreApplication::applicationDirPath()+"/";

#ifdef Q_OS_WIN
pythonHome += "Python";
#else
pythonHome += "python";
#endif
pythonHome = QCoreApplication::applicationDirPath()+"/Python";
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/thirdParty/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ else()
if (APPLE)
set(ROOT_DIR ${FULL_DEST_EXTERNAL_LIBRARIES_DIR}/Python)
else()
set(ROOT_DIR ${FULL_DEST_EXTERNAL_LIBRARIES_DIR}/../python)
set(ROOT_DIR ${FULL_DEST_EXTERNAL_LIBRARIES_DIR}/../Python)
endif()

set(BINARY_DIR bin)
Expand Down

0 comments on commit 08c0c02

Please sign in to comment.