Skip to content

Commit

Permalink
Update to v0.2.0, introducing support for MATLAB R2024b.
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhakk-mw committed Sep 16, 2024
1 parent ff523ac commit fd631be
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 73 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- matlab
baseImage:
- debian:latest
- ubuntu:latest
# Update to ubuntu:latest when R2024b support for it has been released in matlab-deps
- ubuntu:22.04
- mcr.microsoft.com/devcontainers/base:ubuntu
steps:
- uses: actions/checkout@v3
Expand Down
31 changes: 14 additions & 17 deletions src/matlab/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# MATLAB (matlab)

Installs MATLAB with supporting packages and tools.
Expand All @@ -13,28 +12,26 @@ Installs MATLAB with supporting packages and tools.

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| release | MATLAB Release to install. | string | r2024a |
| products | Products to install, specified as a list of space-separated product names.</br> For details of products, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md#product-installation-options). | string | MATLAB |
| doc | Flag to install documentation and examples (R2022b and earlier releases). | boolean | false |
| installGpu | Skips installation of GPU libraries when you install Parallel Computing Toolbox (R2023a and later releases). | boolean | false |
| destination | Full path to the installation destination folder. | string | /opt/matlab/$RELEASE |
| installMatlabProxy | Installs matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installJupyterMatlabProxy | Installs jupyter-matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installMatlabEngineForPython | Installs the MATLAB Engine for Python if the destination option is set correctly. | boolean | false |
| startInDesktop | Starts matlab-proxy when container starts. | string | false |
| networkLicenseManager | MATLAB will use the specified Network License Manager. | string | - |
| skipMATLABInstall | Set to true if you do not want to install MATLAB, for example if you only want to install `matlab-proxy` or `jupyter-matlab-proxy`. | boolean | false |
| Options Id | Description | Type | Default Value |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------- |
| release | MATLAB Release to install. | string | r2024b |
| products | Products to install, specified as a list of space-separated product names.</br> For details of products, see [MATLAB Package Manager](https://github.com/mathworks-ref-arch/matlab-dockerfile/blob/main/MPM.md#product-installation-options). | string | MATLAB |
| doc | Flag to install documentation and examples (R2022b and earlier releases). | boolean | false |
| installGpu | Skips installation of GPU libraries when you install Parallel Computing Toolbox (R2023a and later releases). | boolean | false |
| destination | Full path to the installation destination folder. | string | /opt/matlab/$RELEASE |
| installMatlabProxy | Installs matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installJupyterMatlabProxy | Installs jupyter-matlab-proxy and its dependencies (R2020b and later releases). | boolean | false |
| installMatlabEngineForPython | Installs the MATLAB Engine for Python if the destination option is set correctly. | boolean | false |
| startInDesktop | Starts matlab-proxy when container starts. | string | false |
| networkLicenseManager | MATLAB will use the specified Network License Manager. | string | - |
| skipMATLABInstall | Set to true if you do not want to install MATLAB, for example if you only want to install `matlab-proxy` or `jupyter-matlab-proxy`. | boolean | false |

## Customizations

### VS Code Extensions

- `MathWorks.language-matlab`



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/mathworks/devcontainer-features/blob/main/src/matlab/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/mathworks/devcontainer-features/blob/main/src/matlab/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
31 changes: 16 additions & 15 deletions src/matlab/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": "MATLAB",
"id": "matlab",
"version": "0.1.0",
"version": "0.2.0",
"description": "Installs MATLAB with supporting packages and tools.",
"documentationURL": "https://github.com/mathworks/devcontainer-features",
"options": {
"release": {
"type": "string",
"proposals": [
"r2024a",
"r2023b",
"r2023a",
"r2022b",
"r2022a",
"r2021b",
"r2021a",
"r2020b",
"r2020a",
"r2019b",
"r2019a"
"R2024b",
"R2024a",
"R2023b",
"R2023a",
"R2022b",
"R2022a",
"R2021b",
"R2021a",
"R2020b",
"R2020a",
"R2019b",
"R2019a"
],
"default": "r2024a",
"default": "R2024b",
"description": "MATLAB Release to install."
},
"products": {
Expand All @@ -44,8 +45,8 @@
},
"destination": {
"type": "string",
"default": "/opt/matlab/$RELEASE",
"description": "Full path to the installation destination folder."
"default": "",
"description": "Full path to the installation destination folder. Default: /opt/matlab/${RELEASE^}"
},
"installMatlabProxy": {
"default": false,
Expand Down
6 changes: 3 additions & 3 deletions src/matlab/install-helper-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function ihf_get_remove_cmd() {
# returns "true/false" string if MATLAB_RELEASE is valid
function ihf_is_valid_matlab_release() {
# List of supported MATLAB_RELEASE values
local _SUPPORTED_MATLAB_RELEASES=("r2024a" "r2023b" "r2023a" "r2022b" "r2022a" "r2021b" "r2021a" "r2020b" "r2020a" "r2019b" "r2019a")
local _SUPPORTED_MATLAB_RELEASES=("R2024b" "R2024a" "R2023b" "R2023a" "R2022b" "R2022a" "R2021b" "R2021a" "R2020b" "R2020a" "R2019b" "R2019a")

## Validate MATLAB_RELEASE
if [ -z "$MATLAB_RELEASE" ]; then
Expand Down Expand Up @@ -289,11 +289,11 @@ function test_script() {
ihf_pkg_mgr_update


MATLAB_RELEASE=r2024a
MATLAB_RELEASE=R2024a
is_release_valid=$(ihf_is_valid_matlab_release)
echo "Is $MATLAB_RELEASE valid? Ans: $is_release_valid"

MATLAB_RELEASE=r2023bd
MATLAB_RELEASE=R2023bd
echo "Is $MATLAB_RELEASE valid? Ans: $(ihf_is_valid_matlab_release)"

LINUX_DISTRO=$(ihf_is_debian_or_rhel)
Expand Down
2 changes: 1 addition & 1 deletion src/matlab/install-matlab-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function get_prerequisite_pkgs() {

function get_base_dependencies_list() {
local MATLAB_DEPS_OS_VERSION=$(ihf_get_matlab_deps_os)
local BASE_DEPS_URL=https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE}/${MATLAB_DEPS_OS_VERSION}/base-dependencies.txt
local BASE_DEPS_URL=https://raw.githubusercontent.com/mathworks-ref-arch/container-images/main/matlab-deps/${MATLAB_RELEASE,}/${MATLAB_DEPS_OS_VERSION}/base-dependencies.txt
# Get matlab_deps - if this fails, then we aren't on a supported os
local PKGS=$(wget -qO- ${BASE_DEPS_URL})
if [ -z "$PKGS" ]; then
Expand Down
39 changes: 25 additions & 14 deletions src/matlab/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ set -eu -o pipefail

## Set defaults to all the options in the feature.

# r2024a is the latest available release.
RELEASE="${RELEASE:-"r2024a"}"
# R2024b is the latest available release.
RELEASE="${RELEASE:-"R2024b"}"
PRODUCTS="${PRODUCTS:-"MATLAB"}"
DOC="${DOC:-"false"}"
INSTALLGPU="${INSTALLGPU:-"false"}"
DESTINATION="${DESTINATION:-"/opt/matlab/${RELEASE}"}"
DESTINATION="${DESTINATION:-"/opt/matlab/${RELEASE^}"}"
INSTALLMATLABPROXY="${INSTALLMATLABPROXY:-"false"}"
INSTALLJUPYTERMATLABPROXY="${INSTALLJUPYTERMATLABPROXY:-"false"}"
INSTALLMATLABENGINEFORPYTHON="${INSTALLMATLABENGINEFORPYTHON:-"false"}"
STARTINDESKTOP="${STARTINDESKTOP:-"false"}"
NETWORKLICENSEMANAGER="${NETWORKLICENSEMANAGER:-" "}"
SKIPMATLABINSTALL="${SKIPMATLABINSTALL:-"false"}"

MATLAB_RELEASE="${RELEASE}"
MATLAB_RELEASE="${RELEASE^}"
MATLAB_PRODUCT_LIST="${PRODUCTS}"
MATLAB_INSTALL_LOCATION="${DESTINATION}"

echo "MATLAB_INSTALL_LOCATION: ${MATLAB_INSTALL_LOCATION}"

# Needed by the MATLAB Engine for Python.
# Appends to any existing value of LD_LIBRARY_PATH the path where MATLAB is installed by this script.
_LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+"${LD_LIBRARY_PATH}:"}${MATLAB_INSTALL_LOCATION}/bin/glnxa64"

_CONTAINER_USER_HOME="${_CONTAINER_USER_HOME:-"undefined"}"
_CONTAINER_USER="${_CONTAINER_USER:-"undefined"}"
Expand Down Expand Up @@ -87,17 +92,21 @@ function install_matlab_engine_for_python() {
# Installing the engine is tricky
# The installation can fail if the python version does not match the supported release
declare -A matlabengine_map
matlabengine_map['r2024a']="24.1"
matlabengine_map['r2023b']="23.2"
matlabengine_map['r2023a']="9.14"
matlabengine_map['r2022b']="9.13"
matlabengine_map['r2022a']="9.12"
matlabengine_map['r2021b']="9.11"
matlabengine_map['r2021a']="9.10"
matlabengine_map['r2020b']="9.9"
matlabengine_map['R2024b']="24.2"
matlabengine_map['R2024a']="24.1"
matlabengine_map['R2023b']="23.2"
matlabengine_map['R2023a']="9.14"
matlabengine_map['R2022b']="9.13"
matlabengine_map['R2022a']="9.12"
matlabengine_map['R2021b']="9.11"
matlabengine_map['R2021a']="9.10"
matlabengine_map['R2020b']="9.9"

install_python_and_pip &&
env LD_LIBRARY_PATH=${MATLAB_INSTALL_LOCATION}/bin/glnxa64 \

echo "Setting LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}"

env LD_LIBRARY_PATH=${_LD_LIBRARY_PATH} \
python3 -m pip install matlabengine==${matlabengine_map[$MATLAB_RELEASE]}.*
}

Expand Down Expand Up @@ -216,7 +225,7 @@ if [ "$SKIPMATLABINSTALL" != 'true' ]; then

# Handle GPU installation
if [ "${INSTALLGPU}" == "false" ]; then
RELEASES_THAT_SUPPORT_NOGPU=("r2024a" "r2023b" "r2023a")
RELEASES_THAT_SUPPORT_NOGPU=("R2024b" "R2024a" "R2023b" "R2023a")
# The value variable is assigned a regex that matches the exact value
value="\<${MATLAB_RELEASE}\>"
if [[ ${RELEASES_THAT_SUPPORT_NOGPU[@]} =~ $value ]]; then
Expand All @@ -242,6 +251,8 @@ if [ "$SKIPMATLABINSTALL" != 'true' ]; then
create_home_folder_for_container_user

echo "Proceeding to install matlab as '$_CONTAINER_USER'..."

echo "Install location for MATLAB: ${MATLAB_INSTALL_LOCATION}"

# Switching to container user
su $_CONTAINER_USER
Expand Down
10 changes: 5 additions & 5 deletions src/matlab/tests.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env bash
# Calls conatins to test the install scripts

# Check default installation for r2024a
RELEASE=r2024a
# Check default installation for R2024b
RELEASE=R2024b
RUN_INSTALL_SCRIPT="env RELEASE=${RELEASE} /mounted/src/matlab/install.sh "
# TEST="python3 -m pip list | grep matlabengine && echo PASSED! || echo FAILED!"
docker run -it --rm --entrypoint /usr/bin/sh -v `pwd`:/mounted ubuntu:20.04 -c "$RUN_INSTALL_SCRIPT && echo PASSED! || echo FAILED!"

RELEASE=r2022b
RELEASE=R2022b
RUN_INSTALL_SCRIPT="env RELEASE=${RELEASE} /mounted/src/matlab/install.sh "
# TEST="python3 -m pip list | grep matlabengine && echo PASSED! || echo FAILED!"
docker run -it --rm --entrypoint /usr/bin/sh -v `pwd`:/mounted registry.access.redhat.com/ubi9/ubi:latest -c "$RUN_INSTALL_SCRIPT && echo PASSED! || echo FAILED!"

RELEASE=r2024a
RELEASE=R2024b
RUN_INSTALL_SCRIPT="env RELEASE=${RELEASE} /mounted/src/matlab/install.sh "
# TEST="python3 -m pip list | grep matlabengine && echo PASSED! || echo FAILED!"
docker run -it --rm --entrypoint /usr/bin/bash -v `pwd`:/mounted registry.access.redhat.com/ubi9/ubi:latest

# RELEASE=r2024a
# RELEASE=R2024a
# RUN_INSTALL_SCRIPT="sudo env INSTALLMATLABENGINEFORPYTHON=true SKIPMATLABINSTALL=true _CONTAINER_USER=matlab \
# _CONTAINER_USER_HOME=/home/matlab DESTINATION=/opt/matlab/${RELEASE^} RELEASE=${RELEASE} \
# ~/install/install.sh "
Expand Down
8 changes: 4 additions & 4 deletions test/matlab/check_ubi9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#-------------------------------------------------------------------------------------------------------------
#
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'matlab' feature with the r2024a release, and a support package installed.
# includes the 'matlab' feature with the R2024a release, and a support package installed.
# Support package installation is special, because these packages need to be installed into
# the end users HOME folder and not into the root users folders. Installing into root will
# result in users being unable to access the Support Packages.
Expand All @@ -21,7 +21,7 @@
# "upgradePackages": "true"
# },
# "matlab": {
# "release": "r2024a",
# "release": "R2024a",
# "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors",
# "startInDesktop": "test"
# }
Expand Down Expand Up @@ -50,10 +50,10 @@ source dev-container-features-test-lib
# Verify that the right release is installed in the expected location.
check "is ubi9 " bash -c "cat /etc/os-release | grep 'ID.*rhel' "

check "r2024a is installed" bash -c "cat /opt/matlab/r2024a/VersionInfo.xml | grep '<release>R2023b</release>'"
check "R2024a is installed" bash -c "cat /opt/matlab/R2024a/VersionInfo.xml | grep '<release>R2024a</release>'"

# Verify MATLAB_Support_Package_for_Android_Sensors is installed at the right place (ie: The home folder for the containerUser : vscode )
check "support package is installed" bash -c "cat /home/vscode/Documents/MATLAB/SupportPackages/R2023b/ssiSearchFolders | head -1 | grep 'toolbox/matlab/hardware/shared/hwsdk'"
check "support package is installed" bash -c "cat /home/vscode/Documents/MATLAB/SupportPackages/R2024a/ssiSearchFolders | head -1 | grep 'toolbox/matlab/hardware/shared/hwsdk'"


check "python3 is installed" python3 --version
Expand Down
6 changes: 3 additions & 3 deletions test/matlab/install_matlab_engine_for_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'matlab' feature with
# "image": "mathworks/matlab:r2024a",
# "image": "mathworks/matlab:R2024a",
# "features": {
# "matlab": {
# "destination": "/opt/matlab/R2023b",
# "destination": "/opt/matlab/R2024a",
# "skipMATLABInstall": true,
# "installMatlabEngineForPython": true
# }
Expand Down Expand Up @@ -44,7 +44,7 @@ reportResults


#### Commands to test in container:
# RELEASE=r2024a
# RELEASE=R2024a
# RUN_INSTALL_SCRIPT="sudo env INSTALLMATLABENGINEFORPYTHON=true SKIPMATLABINSTALL=true _CONTAINER_USER=matlab \
# _CONTAINER_USER_HOME=/home/matlab DESTINATION=/opt/matlab/${RELEASE^} RELEASE=${RELEASE} \
# ~/install/install.sh "
Expand Down
11 changes: 11 additions & 0 deletions test/matlab/install_release_on_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

check "r2022b is installed" bash -c "cat /opt/matlab/R2022b/VersionInfo.xml | grep '<release>R2022b</release>'"

# Report results
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
8 changes: 4 additions & 4 deletions test/matlab/install_support_packages_as_container_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#-------------------------------------------------------------------------------------------------------------
#
# This test file will be executed against one of the scenarios devcontainer.json test that
# includes the 'matlab' feature with the r2023a release, and a support package installed.
# includes the 'matlab' feature with the R2022b release, and a support package installed.
# Support package installation is special, because these packages need to be installed into
# the end users HOME folder and not into the root users folders. Installing into root will
# result in users being unable to access the Support Packages.
Expand All @@ -24,7 +24,7 @@
# "installTools": false
# },
# "matlab": {
# "release": "r2023a",
# "release": "R2022b",
# "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors",
# "installMatlabEngineForPython": true
# }
Expand All @@ -50,10 +50,10 @@ source dev-container-features-test-lib
# check <LABEL> <cmd> [args...]

# Verify that the right release is installed in the expected location.
check "r2023a is installed" bash -c "cat /opt/matlab/r2023a/VersionInfo.xml | grep '<release>R2023a</release>'"
check "R2022b is installed" bash -c "cat /opt/matlab/R2022b/VersionInfo.xml | grep '<release>R2022b</release>'"

# Verify MATLAB_Support_Package_for_Android_Sensors is installed at the right place (ie: The home folder for the containerUser : vscode )
check "support package is installed" bash -c "cat /home/vscode/Documents/MATLAB/SupportPackages/R2023a/ssiSearchFolders | head -1 | grep 'toolbox/matlab/hardware/shared/hwsdk'"
check "support package is installed" bash -c "cat /home/vscode/Documents/MATLAB/SupportPackages/R2022b/ssiSearchFolders | head -1 | grep 'toolbox/matlab/hardware/shared/hwsdk'"

check "python3 is installed " bash -c "python3 --version"

Expand Down
Loading

0 comments on commit fd631be

Please sign in to comment.