Skip to content

Commit

Permalink
Merge 81b3061 into 18fb385
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrnz committed Oct 17, 2019
2 parents 18fb385 + 81b3061 commit f10ff8d
Show file tree
Hide file tree
Showing 157 changed files with 10,696 additions and 498 deletions.
207 changes: 172 additions & 35 deletions CMakeLists.txt

Large diffs are not rendered by default.

43 changes: 27 additions & 16 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ macro(build_documentation DOCUMENTATION_NAME)
${PROJECT_BUILD_DIR}/doc/${DOCUMENTATION_NAME}
)

# Make our local target depend on having Python fully installed

add_dependencies(${DOCUMENTATION_BUILD} ${PYTHON_DEPENDENCIES})

# Make our local target depend on our project build target and make our
# documentation build target depend on our local target

Expand Down Expand Up @@ -175,8 +179,8 @@ macro(add_plugin PLUGIN_NAME)
set(OPTIONS)
set(ONE_VALUE_KEYWORDS
EXTERNAL_BINARIES_DIR
EXTERNAL_DESTINATION_DIR
EXTERNAL_SOURCE_DIR
EXTERNAL_DESTINATION_DIR
)
set(MULTI_VALUE_KEYWORDS
SOURCES
Expand All @@ -187,6 +191,7 @@ macro(add_plugin PLUGIN_NAME)
EXTERNAL_BINARIES
SYSTEM_BINARIES
DEPENDS_ON
BYPRODUCTS
TESTS
)

Expand Down Expand Up @@ -276,22 +281,28 @@ macro(add_plugin PLUGIN_NAME)
)
endforeach()

# External binaries

if(NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL "")
# Create a custom target for copying binaries
# Note: this is to prevent Ninja from getting confused with circular
# references...
# Create a custom target for copying external binaries
# Note #1: this is to prevent Ninja from getting confused with circular
# references...
# Note #2: we use this target in the PythonQtAPI build script when setting
# the PYTHON_DEPENDENCIES list...

set(COPY_EXTERNAL_BINARIES_TARGET "COPY_${PROJECT_NAME}_EXTERNAL_BINARIES")
if( NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL ""
OR ( NOT "${ARG_EXTERNAL_SOURCE_DIR}" STREQUAL ""
AND NOT "${ARG_EXTERNAL_DESTINATION_DIR}" STREQUAL ""))
set(COPY_EXTERNAL_BINARIES_TARGET "INSTALL_${PROJECT_NAME}_EXTERNAL_FILES")

add_custom_target(${COPY_EXTERNAL_BINARIES_TARGET})
add_dependencies(${PROJECT_NAME} ${COPY_EXTERNAL_BINARIES_TARGET})

if(NOT "${ARG_DEPENDS_ON}" STREQUAL "")
add_dependencies(${COPY_EXTERNAL_BINARIES_TARGET} ${ARG_DEPENDS_ON})
endif()
endif()

# External binaries

if(NOT "${ARG_EXTERNAL_BINARIES_DIR}" STREQUAL "")
foreach(ARG_EXTERNAL_BINARY ${ARG_EXTERNAL_BINARIES})
# Make sure that the external binary exists

Expand Down Expand Up @@ -371,14 +382,14 @@ macro(add_plugin PLUGIN_NAME)

# Check whether an external package has files to install

if( NOT "${ARG_EXTERNAL_DESTINATION_DIR}" STREQUAL ""
AND NOT "${ARG_EXTERNAL_SOURCE_DIR}" STREQUAL "")

if( NOT "${ARG_EXTERNAL_SOURCE_DIR}" STREQUAL ""
AND NOT "${ARG_EXTERNAL_DESTINATION_DIR}" STREQUAL "")
# Copy the entire source directory to the destination

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
add_custom_command(TARGET ${COPY_EXTERNAL_BINARIES_TARGET}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${ARG_EXTERNAL_SOURCE_DIR}
${ARG_EXTERNAL_DESTINATION_DIR})
${ARG_EXTERNAL_DESTINATION_DIR}
BYPRODUCTS ${ARG_BYPRODUCTS})
endif()

# System binaries
Expand Down Expand Up @@ -657,7 +668,7 @@ endmacro()

#===============================================================================

macro(windows_deploy_qt_plugin PLUGIN_CATEGORY)
macro(windows_deploy_qt_plugins PLUGIN_CATEGORY)
foreach(PLUGIN_NAME ${ARGN})
# Copy the Qt plugin to the plugins folder

Expand Down Expand Up @@ -725,7 +736,7 @@ endmacro()

#===============================================================================

macro(linux_deploy_qt_plugin PLUGIN_CATEGORY)
macro(linux_deploy_qt_plugins PLUGIN_CATEGORY)
foreach(PLUGIN_NAME ${ARGN})
# Copy the Qt plugin to the plugins folder

Expand Down Expand Up @@ -803,7 +814,7 @@ endmacro()

#===============================================================================

macro(macos_deploy_qt_plugin PLUGIN_CATEGORY)
macro(macos_deploy_qt_plugins PLUGIN_CATEGORY)
foreach(PLUGIN_NAME ${ARGN})
# Deploy the Qt plugin

Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions distrib/linux/jupyterconsole.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/runjupyter console --kernel @CMAKE_PROJECT_NAME@ $*
5 changes: 5 additions & 0 deletions distrib/linux/jupyterlab
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/runjupyter lab --ip 127.0.0.1 $*
5 changes: 5 additions & 0 deletions distrib/linux/jupyternotebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

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

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

${appDir}/setpythonpath

export PATH=${appDir}:$PATH

${appDir}/python/bin/jupyter $*
7 changes: 7 additions & 0 deletions distrib/linux/runpython.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

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

${appDir}/setpythonpath

${appDir}/bin/@CMAKE_PROJECT_NAME@ -c Python $*
5 changes: 5 additions & 0 deletions distrib/linux/setpythonpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/python/bin/python ${appDir}/python/bin/setpythonpath.py ${appDir}/python -s
File renamed without changes.
5 changes: 5 additions & 0 deletions distrib/macos/jupyterconsole.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/runjupyter console --kernel @CMAKE_PROJECT_NAME@ $*
5 changes: 5 additions & 0 deletions distrib/macos/jupyterlab
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/runjupyter lab --ip 127.0.0.1 $*
5 changes: 5 additions & 0 deletions distrib/macos/jupyternotebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

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

${appDir}/runjupyter notebook --ip 127.0.0.1 $*
9 changes: 9 additions & 0 deletions distrib/macos/runjupyter.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

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

${appDir}/setpythonpath

export PATH=${appDir}:$PATH

${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python/bin/jupyter $*
7 changes: 7 additions & 0 deletions distrib/macos/runpython.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

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

${appDir}/setpythonpath

${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/MacOS/@CMAKE_PROJECT_NAME@ -c Python $*
8 changes: 8 additions & 0 deletions distrib/macos/setpythonpath.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

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

${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python/bin/python \
${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python/bin/setpythonpath.py \
${appDir}/@CMAKE_PROJECT_NAME@.app/Contents/Frameworks/Python \
-s
7 changes: 7 additions & 0 deletions distrib/windows/jupyterconsole.bat.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ECHO OFF

TITLE Running the Jupyter Lab environment...

SET appDir=%~dp0

CALL "%appDir%runjupyter.bat" console --kernel ${CMAKE_PROJECT_NAME} %*
7 changes: 7 additions & 0 deletions distrib/windows/jupyterlab.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ECHO OFF

TITLE Running the Jupyter Lab environment...

SET appDir=%~dp0

CALL "%appDir%runjupyter.bat" lab --ip 127.0.0.1 %*
10 changes: 10 additions & 0 deletions distrib/windows/jupyterlab.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
shell = CreateObject("WScript.Shell")
appDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)

updatePythonPath = """"&appDir&"\Python\bin\Python.exe"" """&appDir&"\Python\Scripts\setpythonpath.py"" """&appDir&"\Python"" -s"

shell.Run updatePythonPath, 0, True

cmd = """"&appDir&"\Python\bin\Python.exe"" """&appDir&"\Python\Scripts\start_jupyter.py"" lab --ip 127.0.0.1"

shell.Run cmd, 1, False
7 changes: 7 additions & 0 deletions distrib/windows/jupyternotebook.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ECHO OFF

TITLE Running the Jupyter Notebook environment...

SET appDir=%~dp0

CALL "%appDir%runjupyter.bat" notebook --ip 127.0.0.1 %*
10 changes: 10 additions & 0 deletions distrib/windows/jupyternotebook.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
shell = CreateObject("WScript.Shell")
appDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)

updatePythonPath = """"&appDir&"\Python\bin\Python.exe"" """&appDir&"\Python\Scripts\setpythonpath.py"" """&appDir&"\Python"" -s"

shell.Run updatePythonPath, 0, True

cmd = """"&appDir&"\Python\bin\Python.exe"" """&appDir&"\Python\Scripts\start_jupyter.py"" notebook --ip 127.0.0.1"

shell.Run cmd, 1, False
9 changes: 9 additions & 0 deletions distrib/windows/runjupyter.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@ECHO OFF

TITLE Running the Jupyter environment...

SET appDir=%~dp0

CALL "%appDir%setpythonpath.bat"

"%appDir%Python\bin\Python.exe" "%appDir%Python\Scripts\start_jupyter.py" %*
7 changes: 7 additions & 0 deletions distrib/windows/runpython.bat.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ECHO OFF

SET appDir=%~dp0

CALL "%appDir%setpythonpath.bat"

"%appDir%bin\${CMAKE_PROJECT_NAME}" -c Python %*
5 changes: 5 additions & 0 deletions distrib/windows/setpythonpath.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF

SET appDir=%~dp0

"%appDir%Python\bin\Python.exe" "%appDir%Python\Scripts\setpythonpath.py" "%appDir%Python" -s
28 changes: 28 additions & 0 deletions distrib/windows/start_jupyter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import subprocess
import sys

# Get OpenCOR's root directory

root = '\\'.join(sys.executable.split('\\')[:-3])

# Add the location of our binaries to the beginning of the system PATH

path = os.environ['PATH'].split(';')

path.insert(0, '%s\\bin' % root)
path.insert(0, '%s\\Python\\Scripts' % root)
path.insert(0, '%s\\Python\\bin' % root)

os.environ['PATH'] = ';'.join(path)

# Start Jupyter and wait for it to terminate

try:
jupyter = subprocess.Popen(['jupyter'] + sys.argv[1:],
stderr=sys.stderr,
stdout=sys.stdout)

jupyter.wait()
except KeyboardInterrupt:
pass

0 comments on commit f10ff8d

Please sign in to comment.