mpmcreate - Create package - MATLAB (original) (raw)

Create package

Since R2024b

Syntax

Description

`pkg` = mpmcreate([name](#mw%5Ff225614b-7cbe-4575-8b1e-f3c7d33d758b),[location](#mw%5Fb1dbb3ff-7733-4639-917b-98707586b2b1)) creates a package named name from the folder specified bylocation and returns a matlab.mpm.Package object. A package is a collection of MATLAB® code, related files, and a package definition file that defines the package identity and dependencies.

When you create a package using mpmcreate, the package is_installed in place_. In other words, the installed package files and folders are located in the folder specified by location, not in the default installation area.

example

`pkg` = mpmcreate([name](#mw%5Ff225614b-7cbe-4575-8b1e-f3c7d33d758b),[location](#mw%5Fb1dbb3ff-7733-4639-917b-98707586b2b1),[Name=Value](#namevaluepairarguments)) specifies options using one or more name-value arguments. For example, you can specify a package version, identifier, and description.

Examples

collapse all

Create a new package named MyPackage from the folder PackageRootDir.

pkg = mpmcreate("MyPackage","PackageRootDir")

pkg =

Package with properties:

Package Definition Name: "MyPackage" DisplayName: "MyPackage" Version: 1.0.0 (1×1 Version) Summary: "" Description: "" Provider: Folders: [1×0 PackageFolder] (1×0 PackageFolder) Dependencies: "" ReleaseCompatibility: "*" FormerNames: "" ID: "bb9abc84-5324-42fd-851c-b65e2887f3b5"

Package Installation Installed: 1 Editable: 1 InstalledAsDependency: 0 PackageRoot: "C:\MyCode\New Folder\PackageRootDir" InstalledDependencies: "" MissingDependencies: ""

Repository Repository: [0×0 Repository]

help MyPackage

Input Arguments

collapse all

Package name, specified as a string scalar. A valid package name starts with a letter, followed by letters, digits, or underscores. The maximum length of a package name is the value that the namelengthmax command returns.

Example: "MyPackage"

Folder of MATLAB code and related files for the package, specified as a string scalar containing the path to the folder. If the root folder does not contain aresources folder, then the function creates one. The function adds the package definition file mpackage.json to theresources folder. Any other subfolders become member folders.

If the folder specified by location does not exist, then the function creates a new folder and an empty package.

Example: "Repository/PkgRootDir"

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=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: pkg = mpmcreate("myPackage",DisplayName="My MATLAB Package")

Package display name, specified as a string scalar. The display name does not need to be a valid package name.

Example: "Random Number Generator"

Package version, specified as a string scalar containing a valid semantic version or a matlab.mpm.Version object. A valid semantic version consists of three dot-separated numbers in the format: <major version>.<minor version>.<patch version>.

Example: "1.0.1"

Package UUID, specified as a string scalar containing a universally unique identifier (UUID). Multiple versions of the same package have the same UUID.

Package summary, specified as a string scalar.

Example: "Generate random numbers using various pseudorandom algorithms"

Package description, specified as a string scalar.

Example: "RandNumFunc(m,n,algo) creates an m-by-n matrix of random numbers"

Compatible MATLAB versions, specified as a string scalar containing a valid version range. You can specify a single MATLAB version as the full name of a MATLAB release version (for example, "R2024b") or as a semantic version range.

A MATLAB release name follows the format:

For MATLAB releases valid semantic version consists of three dot-separated numbers in the format: <major version>.<minor version>.<patch version>. When you specify a MATLAB version using semantic version syntax, the major version is the last two digits of the release year. The minor version is 1 for "a" releases and 2 for "b" releases. The patch version corresponds to the update version. For example, R2024b has a semantic version of24.2.0. The first update for R2025a has a semantic version of25.1.1. Pre-release status is optional and is specified by adding-prerelease to the end of the version range, for example the prerelease version of R2025b is 25.2.0-prerelease.

A version range can be specified using the <,<=, >, or >= operators in front of a version number. For example >24.2.0 would specify all versions later than R2024b. Multiple ranges separated by whitespace can be specified to further limit matches. For example, >24.2.0 <=24.2.2 would include versions between R2024b and R2024b update 2 but would not include R2025a or R2024b Update 3. Use the || operator to designate multiple acceptable version ranges. For example, <24.2.0 || >24.2.2 would include versions less than R2024b and greater than R2024b update 2 but would not include R2024b update 1.

Example: "R2024b"

Example: "R2024b_Prerelease"

Example: "R2024b_Update1"

Example: "R2024b_Prerelease_Update1"

Example: "24.2.0"

Example: "24.2.1"

Example: "24.2.0-prerelease"

Example: ">=R2024b"

Example: ">24.2.0"

Example: "<24.2.0 || >24.2.2"

Add member folders and their subfolders, specified as a numeric or logical1 (true) or 0 (false). If you specify IncludeSubfolders astrue, then the function adds subfolders oflocation as member folders of the package.

Package root folders, resources folders,private folders, namespace folders, class folders, and their subfolders are not added as member folders.

Install package, specified as a numeric or logical 1 (true) or 0 (false). If you specify Install as true, then the function installs the newly created package.

Tips

Version History

Introduced in R2024b