Command Line Interface

Once the MSL Package Manager has been installed you will be able to install, uninstall, update, list and create MSL packages by using the command line interface.

You can also directly call these functions through the API.

Attention

Since MSL packages are part of a namespace, uninstalling MSL packages using pip uninstall msl-<packaage name> will break the namespace. Therefore, it is recommended to use msl uninstall <packaage name> to uninstall MSL packages.

Note

The information about the MSL repositories that are available on GitHub and the MSL packages on PyPI are cached for 24 hours after you request information about a repository or package. After 24 hours a subsequent request will automatically update the GitHub or PyPI cache. To force the cache to be updated immediately include the --update-cache flag.

To read the help documentation from the command line, run

msl --help

or, for help about a specific command (for example, the install command), run

msl install --help

install

Install all MSL packages that are available

msl install --all

Install all MSL packages without asking for confirmation

msl install --all --yes

Install a specific MSL package, for example msl-loadlib (you can ignore the msl- prefix)

msl install loadlib

Install a package from a git branch (by default the main branch is used if the package is not available on PyPI)

msl install loadlib --branch develop

Install a package from a git tag

msl install loadlib --tag v0.3.0

Install a package from the hash value of a commit

msl install loadlib --commit 12591bade80321c3a165f7a7364ef13f568d622b

Install multiple MSL packages

msl install loadlib equipment qt

Install a specific version of a package (the package must be available as a PyPI package)

msl install loadlib==0.6.0

Specify a version range of a package – make sure to surround the package and version range in quotes (the package must be available as a PyPI package)

msl install "loadlib>=0.4,<0.6"

Install a package and its extra dependencies

msl install loadlib[com]

You can also use a wildcard, for example, to install all packages that start with pr-

msl install pr-*

You can also include all options that the pip install command accepts, run pip help install for more details

msl install loadlib equipment qt --user --retries 10

uninstall

Uninstall all MSL packages (except for the msl-package-manager)

msl uninstall --all

Tip

You can also use remove as an alias for uninstall, e.g., msl remove --all

Note

To uninstall the MSL Package Manager run pip uninstall msl-package-manager. Use with caution. If you uninstall the MSL Package Manager and you still have other MSL packages installed then you may break the MSL namespace.

Uninstall all MSL packages without asking for confirmation

msl uninstall --all --yes

Uninstall a specific MSL package, for example msl-loadlib (you can ignore the msl- prefix)

msl uninstall loadlib

Uninstall multiple MSL packages

msl uninstall loadlib equipment qt

You can also include all options that the pip uninstall command accepts, run pip help uninstall for more details

msl uninstall io qt --no-python-version-warning

update

Update all MSL packages that are installed

msl update --all

Tip

You can also use upgrade as an alias for update, e.g., msl upgrade --all

Update all MSL packages without asking for confirmation

msl update --all --yes

Update a specific MSL package, for example msl-loadlib (you can ignore the msl- prefix)

msl update loadlib

Update to a package that was released <24 hours ago

msl update loadlib --update-cache

Update a package to a git branch (by default the main branch is used if the package is not available on PyPI)

msl update loadlib --branch develop

Update a package to a git tag

msl update loadlib --tag v0.3.0

Update a package using the hash value of a commit

msl update loadlib --commit 12591bade80321c3a165f7a7364ef13f568d622b

Update multiple MSL packages

msl update loadlib equipment qt

You can also include all options that the pip install command accepts, run pip help install for more details (the --upgrade option is automatically included by default)

msl update loadlib io --no-deps

list

List all MSL packages that are installed

msl list

List all MSL repositories that are available on GitHub

msl list --github

List all MSL packages that are available on PyPI

msl list --pypi

Update the GitHub cache and then list all repositories that are available

msl list --github --update-cache

Update the PyPI cache and then list all packages that are available

msl list --pypi --update-cache

Show the information about the repositories (includes information about the branches and the tags) in JSON format

msl list --github --json

create

To create a new package called MyPackage, run

msl create MyPackage

This will create a new folder (in the current working directory) called msl-MyPackage.

To import the package you would use

>>> from msl import MyPackage

Running the create command attempts to determine your user name and email address from your git account to use as the author and email values in the files that it creates. You do not need git to be installed to use the create command, but it helps to make the process more automated. Optionally, you can specify the name to use for the author and the email address by passing additional arguments

msl create MyPackage --author Firstname Lastname --email my.email@address.com

You can also specify where to create the package (instead of the default location which is in the current working directory) by specifying a value for the --dir argument and to automatically accept the default author name and email address values by adding the --yes argument

msl create MyPackage --yes --dir D:\create\package\here

To create a new package that is part of a different namespace, you can run

msl create monochromator --namespace pr

To import this package you would use

>>> from pr import monochromator

To create a new package that is not part of a namespace, run

msl create mypackage --no-namespace

To import this package you would use

>>> import mypackage

authorise

When requesting information about the MSL repositories that are available on GitHub there is a limit to how often you can send requests to the GitHub API (this is the primary reason for caching the information). If you have a GitHub account and include your username and a personal access token with each request then this limit is increased. If you do not have a GitHub account then you could sign up to create an account.

By running this command you will be asked for your GitHub username and personal access token so that you send authorised requests to the GitHub API.

msl authorise

Tip

You can also use authorize as an alias for authorise, e.g., msl authorize

Important

Your GitHub username and personal access token are saved in plain text in the file that is created. You should set the file permissions provided by your operating system to ensure that your GitHub credentials are safe.