diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 73a0dca..4689167 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,9 +16,8 @@ jobs: - matlab baseImage: - debian: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 + - registry.access.redhat.com/ubi9/ubi:latest steps: - uses: actions/checkout@v3 diff --git a/src/matlab/README.md b/src/matlab/README.md index 695b4ac..45cedb7 100644 --- a/src/matlab/README.md +++ b/src/matlab/README.md @@ -7,7 +7,7 @@ Installs MATLAB with supporting packages and tools. ```json "features": { - "ghcr.io/mathworks/devcontainer-features/matlab:0": {} + "ghcr.io/prabhakk-mw/devcontainer-features/matlab:0": {} } ``` @@ -15,13 +15,14 @@ Installs MATLAB with supporting packages and tools. | Options Id | Description | Type | Default Value | |-----|-----|-----|-----| -| release | MATLAB Release to install. | string | R2024b | +| release | MATLAB Release to install. | string | R2025b | | products | Products to install, specified as a list of space-separated product names.
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. Default: /opt/matlab/${RELEASE^} | string | - | | 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 | +| installJupyterLab | Installs jupyterlab | 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 | - | @@ -37,4 +38,4 @@ Installs MATLAB with supporting packages and tools. --- -_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/prabhakk-mw/devcontainer-features/blob/main/src/matlab/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/matlab/devcontainer-feature.json b/src/matlab/devcontainer-feature.json index edf23e9..a37f32b 100644 --- a/src/matlab/devcontainer-feature.json +++ b/src/matlab/devcontainer-feature.json @@ -1,13 +1,15 @@ { "name": "MATLAB", "id": "matlab", - "version": "0.2.0", + "version": "0.3.0", "description": "Installs MATLAB with supporting packages and tools.", "documentationURL": "https://github.com/mathworks/devcontainer-features", "options": { "release": { "type": "string", "proposals": [ + "R2025b", + "R2025a", "R2024b", "R2024a", "R2023b", @@ -21,7 +23,7 @@ "R2019b", "R2019a" ], - "default": "R2024b", + "default": "R2025b", "description": "MATLAB Release to install." }, "products": { @@ -58,6 +60,11 @@ "description": "Installs jupyter-matlab-proxy and its dependencies (R2020b and later releases).", "type": "boolean" }, + "installJupyterLab": { + "default": false, + "description": "Installs jupyterlab", + "type": "boolean" + }, "installMatlabEngineForPython": { "default": false, "description": "Installs the MATLAB Engine for Python if the destination option is set correctly.", @@ -95,8 +102,8 @@ ], "settings": { "MATLAB.indexWorkspace": true, - "MATLAB.installPath": "/usr/local/bin/matlab", - "MATLAB.matlabConnectionTiming": "never", + "MATLAB.signIn": true, + "MATLAB.matlabConnectionTiming": "onDemand", "MATLAB.telemetry": true } } diff --git a/src/matlab/install-helper-functions.sh b/src/matlab/install-helper-functions.sh index 513547f..e98b6d2 100755 --- a/src/matlab/install-helper-functions.sh +++ b/src/matlab/install-helper-functions.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash #------------------------------------------------------------------------------------------------------------- -# Copyright 2024 The MathWorks, Inc. +# Copyright 2024-2025 The MathWorks, Inc. #------------------------------------------------------------------------------------------------------------- # Helpers functions to encapsulate OS specific installation @@ -34,12 +34,11 @@ function ihf_get_matlab_deps_os() { case ${LINUX_DISTRO} in debian) if [[ "${ID}" == "ubuntu" ]]; then - local SUPPORTED_VERSION_CODENAME="focal jammy" MATLAB_DEPS_OS_VERSION=${ID}${VERSION_ID} - elif [[ "${ID}" == "debian" ]]; then - local SUPPORTED_VERSION_CODENAME="bullseye bookworm" + elif [[ "${ID}" == "debian" ]]; then local UBUNTU_VERSION_ID=${VERSION_ID/11/20.04} UBUNTU_VERSION_ID=${UBUNTU_VERSION_ID/12/22.04} + UBUNTU_VERSION_ID=${UBUNTU_VERSION_ID/13/24.04} MATLAB_DEPS_OS_VERSION=ubuntu${UBUNTU_VERSION_ID} fi ;; @@ -136,7 +135,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=("R2024b" "R2024a" "R2023b" "R2023a" "R2022b" "R2022a" "R2021b" "R2021a" "R2020b" "R2020a" "R2019b" "R2019a") + local _SUPPORTED_MATLAB_RELEASES=("R2025b" "R2025a" "R2024b" "R2024a" "R2023b" "R2023a" "R2022b" "R2022a" "R2021b" "R2021a" "R2020b" "R2020a" "R2019b" "R2019a") ## Validate MATLAB_RELEASE if [ -z "$MATLAB_RELEASE" ]; then @@ -164,6 +163,18 @@ function ihf_is_debian_or_rhel() { fi } + +function ihf_is_debian_13 { + . /etc/os-release + if [ "${ID}" = "debian" ] && [ "${VERSION_ID}" = "13" ]; then + # True + return 0 + else + # False + return 1 + fi +} + function ihf_clean_up() { local LINUX_DISTRO=$(ihf_is_debian_or_rhel) case ${LINUX_DISTRO} in diff --git a/src/matlab/install-matlab-deps.sh b/src/matlab/install-matlab-deps.sh index 2b75be8..b113195 100755 --- a/src/matlab/install-matlab-deps.sh +++ b/src/matlab/install-matlab-deps.sh @@ -2,7 +2,7 @@ # This script install the OS dependencies required by MATLAB for the release specified in the # environment variable MATLAB_RELEASE on any linux OS that is dervied from Ubuntu or RHEL #------------------------------------------------------------------------------------------------------------- -# Copyright 2024 The MathWorks, Inc. +# Copyright 2024-2025 The MathWorks, Inc. #------------------------------------------------------------------------------------------------------------- set -eu -o pipefail @@ -43,6 +43,10 @@ function get_base_dependencies_list() { 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 Debian 13, then remove packages which have dpdk in their name + if ihf_is_debian_13; then + PKGS=$(echo $PKGS | tr ' ' '\n' | grep -v 'dpdk' | tr '\n' ' ') + fi if [ -z "$PKGS" ]; then ihf_print_and_exit "${MATLAB_DEPS_OS_VERSION} is not a supported OS for MATLAB ${MATLAB_RELEASE} ." fi @@ -51,7 +55,6 @@ function get_base_dependencies_list() { function install_matlab_deps() { local MATLAB_DEPS_OS_VERSION=$(ihf_get_matlab_deps_os) - # local linux_distro=$(ihf_is_debian_or_rhel) print_os_info diff --git a/src/matlab/install.sh b/src/matlab/install.sh index c5fc3ad..8788d9d 100755 --- a/src/matlab/install.sh +++ b/src/matlab/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash #------------------------------------------------------------------------------------------------------------- -# Copyright 2024 The MathWorks, Inc. +# Copyright 2024-2025 The MathWorks, Inc. #------------------------------------------------------------------------------------------------------------- # NOTE: The 'install.sh' entrypoint script is always executed as the root user. @@ -17,14 +17,15 @@ set -eu -o pipefail ## Set defaults to all the options in the feature. -# R2024b is the latest available release. -RELEASE="${RELEASE:-"R2024b"}" +# R2025b is the latest available release. +RELEASE="${RELEASE:-"R2025b"}" PRODUCTS="${PRODUCTS:-"MATLAB"}" DOC="${DOC:-"false"}" INSTALLGPU="${INSTALLGPU:-"false"}" DESTINATION="${DESTINATION:-"/opt/matlab/${RELEASE^}"}" INSTALLMATLABPROXY="${INSTALLMATLABPROXY:-"false"}" INSTALLJUPYTERMATLABPROXY="${INSTALLJUPYTERMATLABPROXY:-"false"}" +INSTALLJUPYTERLAB="${INSTALLJUPYTERLAB:-"false"}" INSTALLMATLABENGINEFORPYTHON="${INSTALLMATLABENGINEFORPYTHON:-"false"}" STARTINDESKTOP="${STARTINDESKTOP:-"false"}" NETWORKLICENSEMANAGER="${NETWORKLICENSEMANAGER:-" "}" @@ -45,28 +46,33 @@ _CONTAINER_USER="${_CONTAINER_USER:-"undefined"}" _SCRIPT_LOCATION=$(dirname $(readlink -f "$0")) +_PIP_INSTALL="python3 -m pip install" +export PIP_BREAK_SYSTEM_PACKAGES=1 + ### Variable Declaration End ### ### Helper Functions Begin ### export DEBIAN_FRONTEND=noninteractive -function updaterc() { - echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." - if [[ "$(cat /etc/bash.bashrc)" != *"$1"* ]]; then - echo -e "$1" >>/etc/bash.bashrc - fi - if [ -f "/etc/zsh/zshrc" ] && [[ "$(cat /etc/zsh/zshrc)" != *"$1"* ]]; then - echo -e "$1" >>/etc/zsh/zshrc +updaterc() { + local _bashrc + local _zshrc + IS_DEBIAN_OR_RHEL=$(ihf_is_debian_or_rhel) + case $IS_DEBIAN_OR_RHEL in + debian) echo "Updating /etc/bash.bashrc and /etc/zsh/zshrc..." + _bashrc=/etc/bash.bashrc + _zshrc=/etc/zsh/zshrc + ;; + rhel) echo "Updating /etc/bashrc and /etc/zshrc..." + _bashrc=/etc/bashrc + _zshrc=/etc/zshrc + ;; + esac + if [[ "$(cat ${_bashrc})" != *"$1"* ]]; then + echo -e "$1" >> ${_bashrc} fi -} - -function install_python_and_pip() { - if [ "$(ihf_is_debian_or_rhel)" == "rhel" ]; then - # uninstalling python3-requests package as it cannot be updated by subsequent install command. - ihf_remove_packages "python3-requests" + if [ -f "${_zshrc}" ] && [[ "$(cat ${_zshrc})" != *"$1"* ]]; then + echo -e "$1" >> ${_zshrc} fi - ihf_install_packages "python3 python3-pip" && \ - python3 -m pip install --upgrade pip - } function install_xvfb() { @@ -76,22 +82,52 @@ function install_xvfb() { fi } +_INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED=0 +function install_python_and_pip() { + if [ "$_INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED" -eq 0 ]; then + if [ "$(ihf_is_debian_or_rhel)" == "rhel" ]; then + # uninstalling python3-requests package as it cannot be updated by subsequent install command. + ihf_remove_packages "python3-requests" + fi + ihf_install_packages "python3 python3-pip" + _INSTALL_PYTHON_AND_PIP_HAS_BEEN_INSTALLED=1 + else + echo "Python and PIP already installed." + fi +} + +_MATLAB_PROXY_HAS_BEEN_INSTALLED=0 function install_matlab_proxy() { - install_python_and_pip && - install_xvfb && - python3 -m pip install --upgrade matlab-proxy + if [ "$_MATLAB_PROXY_HAS_BEEN_INSTALLED" -eq 0 ]; then + install_python_and_pip + install_xvfb + + $_PIP_INSTALL matlab-proxy + + _MATLAB_PROXY_HAS_BEEN_INSTALLED=1 + else + echo "MATLAB Proxy already installed." + fi } function install_jupyter_matlab_proxy() { - install_python_and_pip && - install_xvfb && - python3 -m pip install --upgrade jupyter-matlab-proxy matlab-proxy jupyterlab jupyterlab-git + install_python_and_pip + $_PIP_INSTALL jupyter-matlab-proxy +} + +function install_jupyterlab() { + install_python_and_pip + $_PIP_INSTALL jupyterlab jupyter } 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 + install_python_and_pip + + # TODO: Skip installation if MATLAB Engine for Python does not support of Python version + # See: https://mathworks.com/support/requirements/python-compatibility.html declare -A matlabengine_map + matlabengine_map['R2025b']="25.2" + matlabengine_map['R2025a']="25.1" matlabengine_map['R2024b']="24.2" matlabengine_map['R2024a']="24.1" matlabengine_map['R2023b']="23.2" @@ -102,12 +138,10 @@ function install_matlab_engine_for_python() { matlabengine_map['R2021a']="9.10" matlabengine_map['R2020b']="9.9" - install_python_and_pip && - echo "Setting LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}" - env LD_LIBRARY_PATH=${_LD_LIBRARY_PATH} \ - python3 -m pip install matlabengine==${matlabengine_map[$MATLAB_RELEASE]}.* + $_PIP_INSTALL matlabengine==${matlabengine_map[$MATLAB_RELEASE]}.* + echo "Setting LD_LIBRARY_PATH=${_LD_LIBRARY_PATH}" } # Create a home folder for non-root, undefined CONTAINER_USER, if not already available @@ -169,6 +203,12 @@ if [ "${INSTALLJUPYTERMATLABPROXY}" == "true" ]; then install_jupyter_matlab_proxy fi +# Install jupyterlab if requested +if [ "${INSTALLJUPYTERLAB}" == "true" ]; then + echo "Installing jupyterlab" + install_jupyterlab +fi + if [ "${STARTINDESKTOP}" == "true" ] || [ "${STARTINDESKTOP}" == "test" ]; then echo "User wants to start in MATLAB Desktop." # Leave a marker file that can be checked by the postStartCommand @@ -202,6 +242,7 @@ fi # Update RC files with the provided license manager info if [ ! -z "${NETWORKLICENSEMANAGER}" -a "${NETWORKLICENSEMANAGER}" != " " ]; then + echo "Saving NLM info to bashrc and zshrc" updaterc "export MLM_LICENSE_FILE=${NETWORKLICENSEMANAGER}" fi @@ -225,7 +266,7 @@ if [ "$SKIPMATLABINSTALL" != 'true' ]; then # Handle GPU installation if [ "${INSTALLGPU}" == "false" ]; then - RELEASES_THAT_SUPPORT_NOGPU=("R2024b" "R2024a" "R2023b" "R2023a") + RELEASES_THAT_SUPPORT_NOGPU=("R2025a" "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 @@ -297,4 +338,5 @@ fi popd ### Script Section End ### echo "MATLAB feature installation is complete." +unset PIP_BREAK_SYSTEM_PACKAGES exit 0 diff --git a/test/matlab/check_ubi9.sh b/test/matlab/check_ubi9.sh index f69e20f..d3d66e9 100644 --- a/test/matlab/check_ubi9.sh +++ b/test/matlab/check_ubi9.sh @@ -1,6 +1,6 @@ #!/bin/bash #------------------------------------------------------------------------------------------------------------- -# Copyright 2024 The MathWorks, Inc. +# Copyright 2024-2025 The MathWorks, Inc. #------------------------------------------------------------------------------------------------------------- # # This test file will be executed against one of the scenarios devcontainer.json test that @@ -9,32 +9,13 @@ # 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. # -# "check_ubi9": { -# "image": "registry.access.redhat.com/ubi9/ubi:latest", -# "features": { -# "ghcr.io/devcontainers/features/common-utils:2": { -# "installZsh": false, -# "installOhMyZshConfig": false, -# "username": "vscode", -# "userUid": "1000", -# "userGid": "1000", -# "upgradePackages": "true" -# }, -# "matlab": { -# "release": "R2024a", -# "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors", -# "startInDesktop": "test" -# } -# }, -# "containerUser": "vscode" -# } # This test can be run with the following command: # # devcontainer features test \ # --features matlab \ # --remote-user root \ -# --base-image mcr.microsoft.com/devcontainers/base:ubuntu \ +# --base-image registry.access.redhat.com/ubi9/ubi:latest \ # `pwd` # OR: # devcontainer features test -p `pwd` -f matlab --filter check_ubi9 --log-level debug @@ -55,17 +36,19 @@ check "R2024a is installed" bash -c "cat /opt/matlab/R2024a/VersionInfo.xml | gr # 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/R2024a/ssiSearchFolders | head -1 | grep 'toolbox/matlab/hardware/shared/hwsdk'" +check "is startInDesktop marker file present" bash -c "ls ~/.teststartmatlabdesktop" -check "python3 is installed" python3 --version +check "NLM information is saved in bashrc " bash -c "echo $MLM_LICENSE_FILE | grep 123@abc.com " -check "matlab-proxy has been installed" bash -c "python3 -m pip list | grep matlab-proxy" +check "python3 is installed " bash -c "python3 --version" -check "matlab-proxy-app is callable" bash -c "matlab-proxy-app -h" +check "matlab-proxy has been installed" bash -c "python3 -m pip list | grep matlab-proxy" -check "is startInDesktop marker file present" bash -c "ls ~/.teststartmatlabdesktop" +check "matlab-proxy-app is callable" bash -c "matlab-proxy-app -v" -check "jupyter-lab is installed" bash -c "jupyter-lab --version" +check "jupyter lab is installed" bash -c "jupyter lab --version" +check "MATLAB Engine for python is installed" bash -c "python3 -m pip list | grep -i 'matlabengine'" # Report results # If any of the checks above exited with a non-zero exit code, the test will fail. reportResults \ No newline at end of file diff --git a/test/matlab/install_support_packages_as_container_user.sh b/test/matlab/check_ubuntu.sh similarity index 64% rename from test/matlab/install_support_packages_as_container_user.sh rename to test/matlab/check_ubuntu.sh index 0a763e3..cc3d2f0 100644 --- a/test/matlab/install_support_packages_as_container_user.sh +++ b/test/matlab/check_ubuntu.sh @@ -1,35 +1,14 @@ #!/bin/bash #------------------------------------------------------------------------------------------------------------- -# Copyright 2024 The MathWorks, Inc. +# Copyright 2024-2025 The MathWorks, Inc. #------------------------------------------------------------------------------------------------------------- # # This test file will be executed against one of the scenarios devcontainer.json test that -# includes the 'matlab' feature with the R2022b release, and a support package installed. +# includes the 'matlab' feature with the R2025b 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. # -# "image": "mcr.microsoft.com/devcontainers/base:ubuntu", -# "features": { -# "ghcr.io/devcontainers/features/common-utils:2": { -# "installZsh": false, -# "installOhMyZshConfig": false, -# "username": "vscode", -# "userUid": "1000", -# "userGid": "1000", -# "upgradePackages": "true" -# }, -# "ghcr.io/devcontainers/features/python": { -# "version": "3.9", -# "installTools": false -# }, -# "matlab": { -# "release": "R2022b", -# "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors", -# "installMatlabEngineForPython": true -# } -# }, -# "containerUser": "vscode" # This test can be run with the following command: # @@ -50,16 +29,24 @@ source dev-container-features-test-lib # check