Skip to content

Commit f729a3a

Browse files
committed
Initial commit
0 parents  commit f729a3a

File tree

13 files changed

+433
-0
lines changed

13 files changed

+433
-0
lines changed

LICENSE.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
MATHWORKS CLOUD REFERENCE ARCHITECTURE LICENSE
2+
3+
The files in this GitHub repository refer to commercial software products and services, virtual machine images, and related materials of The MathWorks, Inc. (“MathWorks Programs”). MathWorks Programs are separately licensed under the MathWorks Software License Agreement, available in the desktop installation of the MathWorks Programs or in the virtual machine image. The files in this GitHub repository may also refer to third-party software licensed under separate terms provided by such third parties.
4+
5+
The following license terms apply only to the files in this GitHub repository, including files in this folder and its subfolders, and do not apply to MathWorks Programs. References to “software” and “code” in the following license terms refer to the files in this GitHub repository.
6+
7+
Copyright (c) 2020, The MathWorks, Inc.
8+
9+
All rights reserved.
10+
11+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12+
13+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
14+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15+
3. In all cases, the software is, and all modifications and derivatives of the software shall be, licensed to you solely for use in conjunction with MathWorks products and service offerings.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
# MATLAB Integration for Jupyter using VNC
3+
4+
The `jupyter-matlab-vnc-proxy` Python® package allows you to integrate MATLAB® with Jupyter®. The MATLAB integration for Jupyter using VNC allows you to connect to a Linux® desktop, with MATLAB installed, from your Jupyter environment.
5+
6+
If you have access to MATLAB R2020b or later, we recommend using the alternative package [`jupyter-matlab-proxy`](https://github.com/mathworks/jupyter-matlab-proxy) which comes with some limitations (see [Specifications and Limitations](https://www.mathworks.com/products/matlab-online/limitations.html)). This alternative enables you to open a MATLAB desktop in a web browser tab, directly from your Jupyter environment.
7+
8+
## Use the MATLAB Integration for Jupyter using VNC
9+
10+
Once you have a Jupyter environment with the `jupyter-matlab-vnc-proxy` package installed, to use the integration, follow these steps:
11+
12+
1. Open your Jupyter environment.
13+
2. If you are using Jupyter Notebook (on the left in figure below), on the `New` menu, select `MATLAB VNC DESKTOP`. If you are using JupyterLab (on the right in figure below), select the `MATLAB VNC DESKTOP` icon on the launcher.
14+
15+
<p align="center">
16+
<img width="600" src="img/combined_launchers_vnc.png">
17+
</p>
18+
19+
3. Wait for the Linux desktop to start. Reload the webpage if the connection fails to load.
20+
4. To use MATLAB, locate the MATLAB icon in the Linux desktop and double click on it and wait for it to start.
21+
22+
## Installation
23+
24+
If you want to install the `jupyter-matlab-vnc-proxy` package in a Jupyter Docker® image, see [Use MATLAB Integration for Jupyter using VNC in a Docker Container](https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter/tree/main/matlab-vnc). Otherwise, if you want to install the `jupyter-matlab-vnc-proxy` package into a preexisting Jupyter environment, follow the instructions below.
25+
26+
To install the `jupyter-matlab-vnc-proxy` package, follow these steps in your Jupyter environment:
27+
28+
1. Install a MATLAB 64 bit Linux version. Make sure the the installation folder is on the system path.
29+
2. Install software packages that MATLAB depends on and software packages that this integration depends on.
30+
For a list of required software packages in a Debian based distribution, inspect [this Dockerfile](https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter/blob/main/matlab-vnc/Dockerfile).
31+
3. Create the environment variable `NOVNC_PATH` and store in it the path to the [`noVNC`](https://github.com/novnc/noVNC) package installed in the previous step.
32+
4. Install the `jupyter-matlab-vnc-proxy` package by executing:
33+
34+
```bash
35+
python -m pip install https://github.com/mathworks/jupyter-matlab-vnc-proxy/archive/0.1.0.tar.gz
36+
```
37+
38+
If you want to use this integration with JupyterLab®, you must also install `jupyterlab-server-proxy` JupyterLab extension. To install the extension, use the following command:
39+
40+
```
41+
jupyter labextension install @jupyterlab/server-proxy
42+
```
43+
44+
For more information see [GUI Launchers](https://jupyter-server-proxy.readthedocs.io/en/latest/launchers.html#jupyterlab-launcher-extension).
45+
46+
47+
### Integration with JupyterHub
48+
49+
If you want to use this integration with JupyterHub®, then you must install the `jupyter-matlab-vnc-proxy` Python package in the Jupyter environment launched by your JupyterHub platform. For example, if your JupyterHub platform launches Docker containers, then install this package in the Docker image used to launch them. You can find a reference architecture that installs the `jupyter-matlab-vnc-proxy` Python package in a Docker image in the repository [Use MATLAB Integration for Jupyter using VNC in a Docker Container](https://github.com/mathworks-ref-arch/matlab-integration-for-jupyter/tree/main/matlab-vnc).
50+
51+
52+
## Feedback
53+
54+
We encourage you to try this repository with your environment and provide feedback – the technical team is monitoring this repository. If you encounter a technical issue or have an enhancement request, send an email to `[email protected]`.

SECURITY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Reporting Security Vulnerabilities
2+
==================================
3+
If you believe you have discovered a security vulnerability, please report it to
4+
[email protected] instead of GitHub. Please see
5+
[MathWorks Vulnerability Disclosure Policy for Security Researchers](https://www.mathworks.com/company/aboutus/policies_statements/vulnerability-disclosure-policy.html)
6+
for additional information.

img/combined_launchers_vnc.png

113 KB
Loading

jupyter_matlab_vnc_proxy/__init__.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2020 The MathWorks, Inc.
2+
3+
import os
4+
import shlex
5+
import tempfile
6+
7+
def setup_desktop():
8+
# Get path to noVNC installation through environment variables
9+
NOVNC_PATH = os.getenv('NOVNC_PATH', '/opt/noVNC')
10+
# make a secure temporary directory for sockets
11+
# This is only readable, writeable & searchable by our uid
12+
sockets_dir = tempfile.mkdtemp()
13+
sockets_path = os.path.join(sockets_dir, 'vnc-socket')
14+
vnc_command = ' '.join((shlex.quote(p) for p in [
15+
'vncserver',
16+
'-verbose',
17+
'-xstartup', os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'xstartup'),
18+
'-geometry', '1680x1050',
19+
'-SecurityTypes', 'None',
20+
'-rfbunixpath', sockets_path,
21+
'-fg',
22+
':1',
23+
]))
24+
return {
25+
'command': [
26+
'websockify', '-v',
27+
'--web', NOVNC_PATH,
28+
'--heartbeat', '30',
29+
'5901',
30+
'--unix-target', sockets_path,
31+
'--',
32+
'/bin/sh', '-c',
33+
f'cd {os.getcwd()} && {vnc_command}'
34+
],
35+
'port': 5901,
36+
'timeout': 30,
37+
'mappath': {'/': '/mw_lite.html'},
38+
'new_browser_window': True,
39+
'launcher_entry': {
40+
'title': 'MATLAB VNC DESKTOP',
41+
'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', 'matlab_icon.svg')
42+
}
43+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Desktop Entry]
2+
Version=1.0
3+
Type=Application
4+
Name=MATLAB R2020b
5+
Exec=bash -c "python $HOME/.local/share/matlab_launcher.py"
6+
Icon=matlab_icon.png
7+
Terminal=false
8+
StartupNotify=true
9+
Categories=Development
Loading

0 commit comments

Comments
 (0)