Main Content

matlab.mpm.PackageSpecifier

Package specifier

Since R2024b

    Description

    A matlab.mpm.PackageSpecifier object stores package identifying information. You can use a package specifier to search for or install packages using mpmsearch or mpminstall.

    Creation

    Description

    pkgspec = matlab.mpm.PackageSpecifier(specstr) creates the package specifier object using the specified string.

    example

    pkgspec = matlab.mpm.PackageSpecifier(specstr,Name=Value), if specstr is just a package name, specifies the VersionRange property, ID property, or both using one or more name-value arguments.

    example

    Input Arguments

    expand all

    Package specifier string, specified as a string scalar in the format "Name", "Name@VersionRange", or "Name@VersionRange@ID".

    Based on the format of the string, this argument sets the Name, VersionRange, and ID properties.

    Example: "MyPackage"

    Example: "MyPackage@>1.2.3"

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: pkgspec = matlab.mpm.PackageSpecifier("MyPackage",VersionRange="1.0.0")

    Version range, specified as a string scalar or character vector.

    Version syntax follows the Semantic Versioning 2.0.0 format: <major version>.<minor version>.<patch version>, where each version number must be a nonnegative integer, for example 1.2.3. You can optionally specify a pre-release version by adding -<pre-release version> to the end of the version, for example 1.2.3-alpha. Optionally specify a build version by adding +<build version>.

    Specify a range of versions by including the <, <=, >, or >= operators in front of a version number. For example, >2.1.13 specifies all versions greater than 2.1.13. Specify more than one range separated by white space to further limit matches. For example, >2.1.13 <=2.1.15 includes versions 2.1.14 and 2.1.15, but not 2.1.13 or 2.1.16. Use the || operator to designate multiple acceptable version ranges. For example, <2.1.13 || >2.1.15 includes versions less than 2.1.13 and greater than 2.1.15, but not 2.1.14.

    This argument sets the VersionRange property.

    Example: VersionRange="1.2.3"

    Example: VersionRange="1.2.3-alpha"

    Example: VersionRange="1.2.3-alpha+exp"

    Example: VersionRange=">2.1.13"

    Example: VersionRange=">2.1.13 <=2.1.15"

    Example: VersionRange="<2.1.13 || >2.1.15"

    Package identifier, specified as a string scalar or character vector containing a unique identifier of the package.

    This argument sets the ID property.

    Example: "0ae7dd2f-9cbc-475b-8141-90c5ae0da371"

    Properties

    expand all

    Package name, specified as a string scalar containing the name of the package.

    Version range, specified as a string scalar containing a semantic version range. By default, this property is "*", which represents all versions.

    Package identifier, specified as a string scalar containing a unique identifier of the package.

    Examples

    collapse all

    Create a package specifier for a package named MyPackage.

    pkgspec = matlab.mpm.PackageSpecifier("MyPackage")
    pkgspec = 
    
      PackageSpecifier with properties:
    
                Name: "MyPackage"
        VersionRange: "*"
                  ID: <missing>

    Create a package specifier for a package named MyPackage, specifying that it is version 1.0.0.

    pkgspec = matlab.mpm.PackageSpecifier("MyPackage",VersionRange="1.0.0")
    pkgspec = 
    
      PackageSpecifier with properties:
    
                Name: "MyPackage"
        VersionRange: "1.0.0"
                  ID: <missing>

    Version History

    Introduced in R2024b