preinstall package¶
Submodules¶
preinstall.depsinstall module¶
- filename
sppas.src.preinstall.depsinstall.py
- author
Florian Hocquet, Brigitte Bigi
- contact
- summary
Manage the installer of SPPAS dependencies.
- class preinstall.depsinstall.sppasInstallerDeps(progress=None)[source]¶
Bases:
object
Main class to manage the installation of external features.
sppasInstallerDeps is a wrapper of Installer Object. It only allows :
to launch the installation process,
to get information, which are important for the users, about the pre-installation.
to configure parameters to get a personalized installation.
For example:
>>> installer = sppasInstallerDeps()
See if a feature is available or not: >>> installer.available(“feature_id”) >>> True
Customize what is enabled or not: >>> installer.enable(“feature_id”) >>> False >>> installer.enable(“feature_id”, True) >>> True
Launch the installation process: >>> errors = installer.install(“feature_id”) >>> assert len(errors) == 0 >>> assert installer.available(“feature_id”) is True
- LIST_OS = {'darwin': <class 'preinstall.installer.MacOsInstaller'>, 'linux': {'debian': <class 'preinstall.installer.DebianInstaller'>, 'fedora': <class 'preinstall.installer.DnfInstaller'>, 'microsoft': <class 'preinstall.installer.DebianInstaller'>, 'mint': <class 'preinstall.installer.DebianInstaller'>, 'suse': <class 'preinstall.installer.RpmInstaller'>, 'ubuntu': <class 'preinstall.installer.DebianInstaller'>}, 'win32': <class 'preinstall.installer.WindowsInstaller'>}¶
- __init__(progress=None)[source]¶
Create a new sppasInstallerDeps instance.
Instantiate the appropriate installer depending on the OS.
- Parameters
progress – (ProcessProgressTerminal) The installation progress.
- available(feat_id)[source]¶
Return True if the feature is available.
- Parameters
feat_id – (str) Identifier of a feature
- brief(feat_id)[source]¶
Return the brief description of the feature.
- Parameters
feat_id – (str) Identifier of a feature
- description(feat_id)[source]¶
Return the description of the feature.
- Parameters
feat_id – (str) Identifier of a feature
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(feat_id)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
feat_id – (str) Identifier of a feature
- Returns
(str) or None
- features_ids(feat_type=None)[source]¶
Return the list of feature identifiers.
- Parameters
feat_type – (str) Only return features of the given type.
- Returns
(list)
preinstall.feature module¶
- filename
sppas.src.preinstall.feature.py
- author
Florian Hocquet, Brigitte Bigi
- contact
- summary
Data structure for one of the feature of SPPAS dependencies.
- class preinstall.feature.AnnotFeature(identifier)[source]¶
Bases:
preinstall.feature.Feature
Store information of one feature required by the application.
Sub-class to represent a the support of an automatic annotation, ie the need to download resources (models, protos…) to enable the automatic annotation.
- class preinstall.feature.DepsFeature(identifier)[source]¶
Bases:
preinstall.feature.Feature
Store information of one feature required by the application.
Sub-class to represent a package to be installed or a command to be executed, or both, ie the need of external programs.
- __init__(identifier)[source]¶
Create a new Feature instance.
- Parameters
identifier – (str) An identifier string.
The identifier must contain at least 2 characters and US-ASCII only. If these requirements are not satisfied, a GUID is used instead.
- set_cmd(value)[source]¶
Set the command to execute.
- Parameters
value – (str) The system command for the OS.
- class preinstall.feature.Feature(identifier)[source]¶
Bases:
object
Store information of one feature required by the application.
- Example
>>> feature = Feature("feature") >>> feature.get_id() >>> "feature" >>> feature.set_enable(True) >>> feature.set_available(True) >>> feature.set_desc("An example of feature") >>> feature.set_packages({"wxpython": ">;4.0"}) >>> feature.set_pypi({"numpy": ">;0.0"}) >>> feature.set_cmd("pip freeze")
- __init__(identifier)[source]¶
Create a new Feature instance.
- Parameters
identifier – (str) An identifier string.
The identifier must contain at least 2 characters and US-ASCII only. If these requirements are not satisfied, a GUID is used instead.
- set_available(value)[source]¶
Set the value of available.
- Parameters
value – (bool) Make the feature available or not.
- set_brief(value)[source]¶
Set the brief description of the feature.
- Parameters
value – (str) The description to describe the feature.
- class preinstall.feature.LangFeature(identifier)[source]¶
Bases:
preinstall.feature.Feature
Store information of one feature required by the application.
Sub-class to represent a language support, ie the need to download linguistic resources of a given language to enable language-dependent automatic annotations.
preinstall.features module¶
- filename
sppas.src.preinstall.acfeatures.py
- author
Florian Hocquet, Brigitte Bigi
- contact
- summary
Manager for all the features of SPPAS dependencies.
- class preinstall.features.Features(req='', cmdos='', filename=None)[source]¶
Bases:
object
Manager of the list of required external features of the software.
- __init__(req='', cmdos='', filename=None)[source]¶
Create a new Features instance.
A Features instance is a container for a list of features. It parses a ‘.ini’ file to get each feature config.
- Parameters
req – (str)
cmdos – (str)
- annot(fid)[source]¶
Return the name the annotation resource to download.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- available(fid, value=None)[source]¶
Return True if the feature is available and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Make the feature available or not.
- brief(fid)[source]¶
Return the brief description of the feature.
- Parameters
fid – (str) Identifier of a feature
- cmd(fid)[source]¶
Return the command to execute for the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- description(fid)[source]¶
Return the description of the feature
- Parameters
fid – (str) Identifier of a feature
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(fid)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
fid – (str) Identifier of a feature
- get_ids(feat_type=None)[source]¶
Return the list of feature identifiers of the given type.
- Parameters
feat_type – (str) Feature type, or None to get all ids
- Returns
(list) Feature identifiers
- lang(fid)[source]¶
Return the lang code of the linguistic resource to download.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- packages(fid)[source]¶
Return the dictionary of system dependencies of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(dict) key=package; value=version
- pypi(fid)[source]¶
Return the dictionary of pip dependencies of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(dict) key=package; value=version
- set_features()[source]¶
Browses the features.ini file and instantiate a Feature().
Only unix-based systems can have package requirements. If they don’t, the corresponding req_ attribute is missing or empty or with “nil”.
A feature is not available for a system, if none of the corresponding “cmd_” and “req_” and the “pip” attributes are defined.
preinstall.installer module¶
- filename
sppas.src.preinstall.installer.py
- author
Florian Hocquet, Brigitte Bigi
- contact
- summary
Multi-platform installer system of SPPAS dependencies
- class preinstall.installer.DebianInstaller[source]¶
Bases:
preinstall.installer.Installer
An installer for Debian-based package manager systems.
This DebianInstaller(Installer) is made for the apt package installer, like Debian, Ubuntu or Mint.
- class preinstall.installer.DnfInstaller[source]¶
Bases:
preinstall.installer.Installer
An installer for DNF-based package manager systems.
- Author
Florian Hocquet
- Organization
Laboratoire Parole et Langage, Aix-en-Provence, France
- Contact
- License
GPL, v3
- Copyright
Copyright (C) 2011-2020 Brigitte Bigi
- Summary
a script to use workspaces from terminal
This DNF is made for linux distributions like Fedora.
- class preinstall.installer.Installer[source]¶
Bases:
object
Manage the installation of external required or optional features.
It will browse the Features() to install, according to the OS of the computer. Must be sub-classed to create the appropriate Features(). Then, the installation is launched with:
>>> class SubInstaller(Installer): >>> def __init__(self): >>> super(SubInstaller, self).__init__() >>> self._features = Features(req="", cmdos="") >>> SubInstaller().install()
- available(fid, value=None)[source]¶
Return True if the feature is available and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Make the feature available or not.
- brief(fid)[source]¶
Return the brief description of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- ckeck_pypis()[source]¶
Update the app config file for features depending on pip packages.
CAUTION: it is supposed that if the PIP dependency is satisfied, the feature can be enabled. It is currently True but it could be false…
- Parameters
fid – (str) Identifier of a feature
- Raises
sppasInstallationError
- description(fid)[source]¶
Return the long description of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(fid)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
fid – (str) Identifier of a feature
- get_fids(feat_type=None)[source]¶
Return the list of feature identifiers.
- Parameters
feat_type – (str) Only return features of the given type.
- Returns
(list)
- install(feat_type=None)[source]¶
Process the installation.
- Parameters
feat_type – (str) Install only features of the given type. None to install all.
- Returns
(list) Error messages.
- static install_resource(web_url, zip_path)[source]¶
Install the given zip file in the resources of SPPAS.
- Parameters
web_url – (str) URL of the directory
zip_path – (str) Zip filename to download and install
- class preinstall.installer.MacOsInstaller[source]¶
Bases:
preinstall.installer.Installer
An installer for MacOS systems.
- Author
Florian Hocquet
- Organization
Laboratoire Parole et Langage, Aix-en-Provence, France
- Contact
- License
GPL, v3
- Copyright
Copyright (C) 2011-2020 Brigitte Bigi
- class preinstall.installer.RpmInstaller[source]¶
Bases:
preinstall.installer.Installer
An installer for RPM-based package manager system.
- Author
Florian Hocquet
- Organization
Laboratoire Parole et Langage, Aix-en-Provence, France
- Contact
- License
GPL, v3
- Copyright
Copyright (C) 2011-2020 Brigitte Bigi
This RPM is made for the linux distributions like RedHat, or Suse.
- class preinstall.installer.WindowsInstaller[source]¶
Bases:
preinstall.installer.Installer
An installer for Microsoft Windows system.
- Author
Florian Hocquet
- Organization
Laboratoire Parole et Langage, Aix-en-Provence, France
- Contact
- License
GPL, v3
- Copyright
Copyright (C) 2011-2020 Brigitte Bigi
This WindowsInstaller installer was tested with WindowsInstaller 10.
Module contents¶
- filename
sppas.src.preinstall.__init__.py
- author
Brigitte Bigi
- contact
- summary
Package for the management of SPPAS dependencies.
Compatible only with Python 3+.
- This package allows to:
Install external programs with pip, a command manager or a command;
Install linguistic resources;
Install annotation resources.
Requires:
config
- class preinstall.Features(req='', cmdos='', filename=None)[source]¶
Bases:
object
Manager of the list of required external features of the software.
- __init__(req='', cmdos='', filename=None)[source]¶
Create a new Features instance.
A Features instance is a container for a list of features. It parses a ‘.ini’ file to get each feature config.
- Parameters
req – (str)
cmdos – (str)
- annot(fid)[source]¶
Return the name the annotation resource to download.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- available(fid, value=None)[source]¶
Return True if the feature is available and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Make the feature available or not.
- brief(fid)[source]¶
Return the brief description of the feature.
- Parameters
fid – (str) Identifier of a feature
- cmd(fid)[source]¶
Return the command to execute for the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- description(fid)[source]¶
Return the description of the feature
- Parameters
fid – (str) Identifier of a feature
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(fid)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
fid – (str) Identifier of a feature
- get_ids(feat_type=None)[source]¶
Return the list of feature identifiers of the given type.
- Parameters
feat_type – (str) Feature type, or None to get all ids
- Returns
(list) Feature identifiers
- lang(fid)[source]¶
Return the lang code of the linguistic resource to download.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- packages(fid)[source]¶
Return the dictionary of system dependencies of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(dict) key=package; value=version
- pypi(fid)[source]¶
Return the dictionary of pip dependencies of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(dict) key=package; value=version
- set_features()[source]¶
Browses the features.ini file and instantiate a Feature().
Only unix-based systems can have package requirements. If they don’t, the corresponding req_ attribute is missing or empty or with “nil”.
A feature is not available for a system, if none of the corresponding “cmd_” and “req_” and the “pip” attributes are defined.
- class preinstall.Installer[source]¶
Bases:
object
Manage the installation of external required or optional features.
It will browse the Features() to install, according to the OS of the computer. Must be sub-classed to create the appropriate Features(). Then, the installation is launched with:
>>> class SubInstaller(Installer): >>> def __init__(self): >>> super(SubInstaller, self).__init__() >>> self._features = Features(req="", cmdos="") >>> SubInstaller().install()
- available(fid, value=None)[source]¶
Return True if the feature is available and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Make the feature available or not.
- brief(fid)[source]¶
Return the brief description of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- ckeck_pypis()[source]¶
Update the app config file for features depending on pip packages.
CAUTION: it is supposed that if the PIP dependency is satisfied, the feature can be enabled. It is currently True but it could be false…
- Parameters
fid – (str) Identifier of a feature
- Raises
sppasInstallationError
- description(fid)[source]¶
Return the long description of the feature.
- Parameters
fid – (str) Identifier of a feature
- Returns
(str)
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(fid)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
fid – (str) Identifier of a feature
- get_fids(feat_type=None)[source]¶
Return the list of feature identifiers.
- Parameters
feat_type – (str) Only return features of the given type.
- Returns
(list)
- install(feat_type=None)[source]¶
Process the installation.
- Parameters
feat_type – (str) Install only features of the given type. None to install all.
- Returns
(list) Error messages.
- static install_resource(web_url, zip_path)[source]¶
Install the given zip file in the resources of SPPAS.
- Parameters
web_url – (str) URL of the directory
zip_path – (str) Zip filename to download and install
- class preinstall.sppasInstallerDeps(progress=None)[source]¶
Bases:
object
Main class to manage the installation of external features.
sppasInstallerDeps is a wrapper of Installer Object. It only allows :
to launch the installation process,
to get information, which are important for the users, about the pre-installation.
to configure parameters to get a personalized installation.
For example:
>>> installer = sppasInstallerDeps()
See if a feature is available or not: >>> installer.available(“feature_id”) >>> True
Customize what is enabled or not: >>> installer.enable(“feature_id”) >>> False >>> installer.enable(“feature_id”, True) >>> True
Launch the installation process: >>> errors = installer.install(“feature_id”) >>> assert len(errors) == 0 >>> assert installer.available(“feature_id”) is True
- LIST_OS = {'darwin': <class 'preinstall.installer.MacOsInstaller'>, 'linux': {'debian': <class 'preinstall.installer.DebianInstaller'>, 'fedora': <class 'preinstall.installer.DnfInstaller'>, 'microsoft': <class 'preinstall.installer.DebianInstaller'>, 'mint': <class 'preinstall.installer.DebianInstaller'>, 'suse': <class 'preinstall.installer.RpmInstaller'>, 'ubuntu': <class 'preinstall.installer.DebianInstaller'>}, 'win32': <class 'preinstall.installer.WindowsInstaller'>}¶
- __init__(progress=None)[source]¶
Create a new sppasInstallerDeps instance.
Instantiate the appropriate installer depending on the OS.
- Parameters
progress – (ProcessProgressTerminal) The installation progress.
- available(feat_id)[source]¶
Return True if the feature is available.
- Parameters
feat_id – (str) Identifier of a feature
- brief(feat_id)[source]¶
Return the brief description of the feature.
- Parameters
feat_id – (str) Identifier of a feature
- description(feat_id)[source]¶
Return the description of the feature.
- Parameters
feat_id – (str) Identifier of a feature
- enable(fid, value=None)[source]¶
Return True if the feature is enabled and/or set it.
- Parameters
fid – (str) Identifier of a feature
value – (bool or None) Enable of disable the feature.
- feature_type(feat_id)[source]¶
Return the feature type: deps, lang, annot.
- Parameters
feat_id – (str) Identifier of a feature
- Returns
(str) or None
- features_ids(feat_type=None)[source]¶
Return the list of feature identifiers.
- Parameters
feat_type – (str) Only return features of the given type.
- Returns
(list)