API Usage
In cases where using the command-line interface is not desired, you can use the API functions directly to install, uninstall, update, list and create MSL packages.
First, import the MSL Package Manager
>>> from msl import package_manager as pm
Tip
You can set what information is displayed on the screen by changing the Logging Levels
>>> import logging
>>> pm.set_log_level(logging.INFO)
install
install
the msl-network and msl-qt packages
>>> pm.install('network', 'qt')
The following MSL packages will be INSTALLED:
msl-network 0.5.0 [PyPI]
msl-qt [GitHub]
Proceed (Y/n)?
uninstall
uninstall
the msl-loadlib package
>>> pm.uninstall('loadlib')
The following MSL packages will be REMOVED:
msl-loadlib 0.6.0
Proceed (Y/n)?
update
update
the msl-loadlib package
>>> pm.update('loadlib')
The following MSL packages will be UPDATED:
msl-loadlib 0.6.0 --> 0.7.0 [PyPI]
Proceed (Y/n)?
list
Display the information about the MSL packages that are installed, see info()
>>> pm.info()
MSL Package Version Description
------------------- ------- ----------------------------------------------------------------------
msl-loadlib 0.6.0 Load a shared library (and access a 32-bit library from 64-bit Python)
msl-package-manager 2.4.0 Install, uninstall, update, list and create MSL packages
Display the information about the MSL repositories that are available
>>> pm.info(from_github=True)
MSL Repository Version Description
------------------- ------- ----------------------------------------------------------------------
GTC 1.2.1 The GUM Tree Calculator for Python
Quantity-Value 0.1.0 A package that supports physical quantity-correctness in Python code
msl-equipment Manage and communicate with equipment in the laboratory
msl-io Read and write data files
msl-loadlib 0.7.0 Load a shared library (and access a 32-bit library from 64-bit Python)
msl-network 0.5.0 Concurrent and asynchronous network I/O
msl-package-manager 2.4.0 Install, uninstall, update, list and create MSL packages
msl-qt Custom Qt components for the user interface
Get a dictionary of all MSL packages that are installed()
>>> pkgs = pm.installed()
>>> for pkg, info in pkgs.items():
... print(pkg, info)
...
msl-loadlib {'version': '0.6.0', 'description': 'Load a shared library (and access a 32-bit library from 64-bit Python)', 'repo_name': 'msl-loadlib'}
msl-package-manager {'version': '2.4.0', 'description': 'Install, uninstall, update, list and create MSL packages', 'repo_name': 'msl-package-manager'}
Get a dictionary of all MSL repositories on GitHub, see github()
>>> pkgs = pm.github()
>>> for key, value in pkgs['msl-package-manager'].items():
... print('{}: {}'.format(key, value))
...
description: Install, uninstall, update, list and create MSL packages
version: 2.4.0
tags: ['v2.4.0', 'v2.3.0', 'v2.2.0', 'v2.1.0', 'v2.0.0', 'v1.5.1', 'v1.5.0', 'v1.4.1', 'v1.4.0', 'v1.3.0', 'v1.2.0', 'v1.1.0', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.1.0']
branches: ['main']
Get a dictionary of all MSL packages on PyPI, see pypi()
>>> pkgs = pm.pypi()
>>> pkgs['msl-package-manager']
{'description': 'Install, uninstall, update, list and create MSL packages', 'version': '2.4.0'}
create
create
a new MSL-MyPackage package
>>> pm.create('MyPackage', author='my name', email='my@email.com', directory='D:/create/here')
Created msl-MyPackage in 'D:/create/here\\msl-MyPackage'