From fd631be1dafc9f0605d367b504f35a58d2077cf5 Mon Sep 17 00:00:00 2001 From: Prabhakar Kumar Date: Mon, 16 Sep 2024 11:47:42 +0000 Subject: [PATCH] Update to v0.2.0, introducing support for MATLAB R2024b. --- .github/workflows/test.yaml | 3 +- src/matlab/README.md | 31 +++++++-------- src/matlab/devcontainer-feature.json | 31 ++++++++------- src/matlab/install-helper-functions.sh | 6 +-- src/matlab/install-matlab-deps.sh | 2 +- src/matlab/install.sh | 39 ++++++++++++------- src/matlab/tests.sh | 10 ++--- test/matlab/check_ubi9.sh | 8 ++-- .../install_matlab_engine_for_python.sh | 6 +-- test/matlab/install_release_on_ubuntu.sh | 11 ++++++ ...tall_support_packages_as_container_user.sh | 8 ++-- test/matlab/scenarios.json | 15 +++++-- test/matlab/test.sh | 6 +-- 13 files changed, 103 insertions(+), 73 deletions(-) create mode 100644 test/matlab/install_release_on_ubuntu.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 59339d1..73a0dca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 diff --git a/src/matlab/README.md b/src/matlab/README.md index 708b88f..a57e394 100644 --- a/src/matlab/README.md +++ b/src/matlab/README.md @@ -1,4 +1,3 @@ - # MATLAB (matlab) Installs MATLAB with supporting packages and tools. @@ -13,19 +12,19 @@ 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.
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.
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 @@ -33,8 +32,6 @@ Installs MATLAB with supporting packages and tools. - `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`._ diff --git a/src/matlab/devcontainer-feature.json b/src/matlab/devcontainer-feature.json index bc8f4d5..edf23e9 100644 --- a/src/matlab/devcontainer-feature.json +++ b/src/matlab/devcontainer-feature.json @@ -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": { @@ -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, diff --git a/src/matlab/install-helper-functions.sh b/src/matlab/install-helper-functions.sh index b37dd22..513547f 100755 --- a/src/matlab/install-helper-functions.sh +++ b/src/matlab/install-helper-functions.sh @@ -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 @@ -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) diff --git a/src/matlab/install-matlab-deps.sh b/src/matlab/install-matlab-deps.sh index 8bac277..2b75be8 100755 --- a/src/matlab/install-matlab-deps.sh +++ b/src/matlab/install-matlab-deps.sh @@ -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 diff --git a/src/matlab/install.sh b/src/matlab/install.sh index 0690793..c5fc3ad 100755 --- a/src/matlab/install.sh +++ b/src/matlab/install.sh @@ -17,12 +17,12 @@ 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"}" @@ -30,10 +30,15 @@ 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"}" @@ -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]}.* } @@ -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 @@ -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 diff --git a/src/matlab/tests.sh b/src/matlab/tests.sh index 6b5322f..47a3b1c 100755 --- a/src/matlab/tests.sh +++ b/src/matlab/tests.sh @@ -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 " diff --git a/test/matlab/check_ubi9.sh b/test/matlab/check_ubi9.sh index 3865c2d..f69e20f 100644 --- a/test/matlab/check_ubi9.sh +++ b/test/matlab/check_ubi9.sh @@ -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. @@ -21,7 +21,7 @@ # "upgradePackages": "true" # }, # "matlab": { -# "release": "r2024a", +# "release": "R2024a", # "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors", # "startInDesktop": "test" # } @@ -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 'R2023b'" +check "R2024a is installed" bash -c "cat /opt/matlab/R2024a/VersionInfo.xml | grep 'R2024a'" # 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 diff --git a/test/matlab/install_matlab_engine_for_python.sh b/test/matlab/install_matlab_engine_for_python.sh index 1b35e6c..2915dfa 100644 --- a/test/matlab/install_matlab_engine_for_python.sh +++ b/test/matlab/install_matlab_engine_for_python.sh @@ -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 # } @@ -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 " diff --git a/test/matlab/install_release_on_ubuntu.sh b/test/matlab/install_release_on_ubuntu.sh new file mode 100644 index 0000000..99a4f1b --- /dev/null +++ b/test/matlab/install_release_on_ubuntu.sh @@ -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 'R2022b'" + +# 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/install_support_packages_as_container_user.sh index cdd6878..0a763e3 100644 --- a/test/matlab/install_support_packages_as_container_user.sh +++ b/test/matlab/install_support_packages_as_container_user.sh @@ -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. @@ -24,7 +24,7 @@ # "installTools": false # }, # "matlab": { -# "release": "r2023a", +# "release": "R2022b", # "products": "MATLAB MATLAB_Support_Package_for_Android_Sensors", # "installMatlabEngineForPython": true # } @@ -50,10 +50,10 @@ source dev-container-features-test-lib # check