module installhelper.module_install

Inheritance diagram of pymyinstall.installhelper.module_install

Short summary

module pymyinstall.installhelper.module_install

Various function to install various python module from various location.

source on GitHub

Classes

class

truncated documentation

ModuleInstall

defines the necessary information for a module

Functions

function

truncated documentation

_filter_pip_out

Properties

property

truncated documentation

ImportName

return the import name

Purpose

returns the comment

Script

returns the script to run if the extension is an application and not a module

Static Methods

staticmethod

truncated documentation

clear_cache

clear the local cache to get wheel link

is_annoying

some modules are not available on pipy

Methods

method

truncated documentation

__cmp__

to sort modules

__init__

__lt__

overload operator <

__repr__

usual

__str__

usual

_check_installation

some modules uninstall and install modules with another version number, we try to track that

as_dict

returns the members in a dictionary

copy

copy the module, if version is not None, change the version number

download

Downloads the module without installation.

extract_version

extract the version from a filename

get_exewheel_url_link

for windows, get the url of the setup using a webpage

get_exewheel_url_link2

for windows, get the url of the setup using a webpage

get_installed_classifier

return the classifier of the installed package

get_installed_license

return the license of the installed package

get_installed_metadata

return the metadata of the installed package

get_installed_numeric_version

returns the version as number (not string)

get_installed_version

return the version of the installed package

get_pypi_numeric_version

returns the version of a package in pypi

get_pypi_version

returns the version of a package on pypi

has_update

tells if the package has a newer version on pipy

install

Installs the package.

is_installed_local

checks if a module is installed

is_installed_local_cmd

Test the module by running a command line. Does some others verifications for a specific modules such as scipy.

is_installed_version

tells if a module is installed

module_install_preprocess

Run some preprocessing for specific modules

run_post_installation

Run instructions post installation

unzipfiles

unzip files from a zip archive

update

Updates the package if necessary, we use pip install <module_name> --upgrade --no-deps,

Documentation

Various function to install various python module from various location.

source on GitHub

class pymyinstall.installhelper.module_install.ModuleInstall(name, kind='pip', gitrepo=None, mname=None, fLOG=<built-in function print>, version=None, script=None, index_url=None, deps=None, purpose=None, usage=None, web=None, source=None, custom=None, branch='master', pip_options=None, overwrite=None, post=None, skip_import=False, pipgit=False)

Bases: object

defines the necessary information for a module

Installation from GitHub

ModuleInstall("pyquickhelper", "github",
              "sdpython").install(temp_folder="temp")

source on GitHub

Parameters:
  • name – name

  • kind – kind of installation (pip, github, wheel)

  • gitrepo – github repository (example: sdpython)

  • mname – sometimes, the module name is different from its official name

  • version – to install a specific version (None for the latest)

  • fLOG – logging function

  • script – some extensions are not a module but an application (such as spyder), the class will check this script is available

  • deps – overwrite deps parameters when installing the module

  • index_url – to get the package from a custom pypi server

  • purpose – purpose of the module

  • usage – main usage for the module

  • web – website for the module, if None, default to pipy

  • source – to overwrite parameter source of methods download, install() or update().

  • custom – custom instructions to install, usually ['build', 'install'] to run setup.py build and setup.py install

  • branch – only necessary for install process with github

  • pip_options – additional options for pip (list)

  • overwrite – overwrite the location of the wheel

  • post – instructions post installation (look for this parameter in the code to see what is supported)

  • pipgit – install the module with pip + git instead of getting the full archive

  • skip_import – added to indicate the module cannot be imported

Changed in version 1.1: Parameters source, custom, branch, pip_options, overwrite, post were added. Parameter skip_import was introduced to skip the checking of the installation. Parameter pipgit was added.

source on GitHub

property ImportName

return the import name

source on GitHub

property Purpose

returns the comment

source on GitHub

property Script

returns the script to run if the extension is an application and not a module

source on GitHub

__cmp__(o)

to sort modules

Parameters:

o – other module

Returns:

-1, 0, 1

source on GitHub

__init__(name, kind='pip', gitrepo=None, mname=None, fLOG=<built-in function print>, version=None, script=None, index_url=None, deps=None, purpose=None, usage=None, web=None, source=None, custom=None, branch='master', pip_options=None, overwrite=None, post=None, skip_import=False, pipgit=False)
Parameters:
  • name – name

  • kind – kind of installation (pip, github, wheel)

  • gitrepo – github repository (example: sdpython)

  • mname – sometimes, the module name is different from its official name

  • version – to install a specific version (None for the latest)

  • fLOG – logging function

  • script – some extensions are not a module but an application (such as spyder), the class will check this script is available

  • deps – overwrite deps parameters when installing the module

  • index_url – to get the package from a custom pypi server

  • purpose – purpose of the module

  • usage – main usage for the module

  • web – website for the module, if None, default to pipy

  • source – to overwrite parameter source of methods download, install() or update().

  • custom – custom instructions to install, usually ['build', 'install'] to run setup.py build and setup.py install

  • branch – only necessary for install process with github

  • pip_options – additional options for pip (list)

  • overwrite – overwrite the location of the wheel

  • post – instructions post installation (look for this parameter in the code to see what is supported)

  • pipgit – install the module with pip + git instead of getting the full archive

  • skip_import – added to indicate the module cannot be imported

Changed in version 1.1: Parameters source, custom, branch, pip_options, overwrite, post were added. Parameter skip_import was introduced to skip the checking of the installation. Parameter pipgit was added.

source on GitHub

__lt__(o)

overload operator <

Parameters:

o – other module

Returns:

boolean

source on GitHub

__repr__()

usual

source on GitHub

__str__()

usual

source on GitHub

_check_installation()

some modules uninstall and install modules with another version number, we try to track that

source on GitHub

_page_cache_html = 'somewhere/workspace/pymyinstall/pymyinstall_UT_39_std/_doc/sphinxdoc/source/pymyinstall/installhelper/page.html'
_page_cache_html2 = 'somewhere/workspace/pymyinstall/pymyinstall_UT_39_std/_doc/sphinxdoc/source/pymyinstall/installhelper/page2.html'
as_dict(rst_link=False)

returns the members in a dictionary

Parameters:

rst_link – if True, add rst_link, license, classifier

Returns:

dictionary

source on GitHub

static clear_cache()

clear the local cache to get wheel link

source on GitHub

copy(version=None)

copy the module, if version is not None, change the version number

Parameters:

version – version number or None for unchanged

Returns:

ModuleInstall

New in version 1.0.

source on GitHub

download(temp_folder='.', force=False, unzipFile=True, file_save=None, deps=False, source=None)

Downloads the module without installation.

Parameters:
  • temp_folder – destination

  • force – force the installation even if already installed

  • unzipFile – if it can be unzipped, it will be (for github, mostly)

  • file_save – for debug purposes, do not change it unless you know what you are doing

  • deps – download the dependencies too (only available for pip)

  • source – overwrite source of the download, only for wheel packages, see get_exewheel_url_link2

Returns:

downloaded files

deps is overwritten by self.deps if not None If source is None, it is overwritten by self.source.

source on GitHub

extract_version(name)

extract the version from a filename

Parameters:

name – filename

Returns:

verions (str)

source on GitHub

for windows, get the url of the setup using a webpage

Parameters:
  • file_save – for debug purposes

  • wheel – returns the wheel file or the exe file

Returns:

url, exe name

source on GitHub

get_exewheel_url_link2(file_save=None, wheel=False, source=None)

for windows, get the url of the setup using a webpage

Parameters:
  • file_save – for debug purposes

  • wheel – returns the wheel file or the exe file

  • source – source of the wheels (ex: 2 or http://...)

Returns:

url, exe name

Changed in version 1.1: Parameter source was added.

source on GitHub

get_installed_classifier()

return the classifier of the installed package

Returns:

string

source on GitHub

get_installed_license()

return the license of the installed package

Returns:

string

source on GitHub

get_installed_metadata()

return the metadata of the installed package

Returns:

dictionary

source on GitHub

get_installed_numeric_version()

returns the version as number (not string)

Returns:

tuple

source on GitHub

get_installed_version()

return the version of the installed package

Returns:

version

source on GitHub

get_pypi_numeric_version()

returns the version of a package in pypi

Returns:

tuple

source on GitHub

get_pypi_version(url='https://pypi.python.org/pypi')

returns the version of a package on pypi

Parameters:

url – pipy server

Returns:

version

See also installing_python_packages_programatically.py, pkgtools.pypi: PyPI interface.

source on GitHub

has_update()

tells if the package has a newer version on pipy

Returns:

boolean

source on GitHub

install(force_kind=None, force=False, temp_folder='.', log=False, options=None, deps=False, source=None, custom=None, post=None, out_streams=None)

Installs the package.

Parameters:
  • force_kind – overwrite self.kind

  • force – force the installation even if already installed

  • temp_folder – folder where to download the setup

  • log – display logs or not

  • options – other options to add to the command line (see below) in a list

  • deps – install the dependencies too (only available for pip)

  • source – overwrite the source of the wheels, see get_exewheel_url_link2

  • custom – overwrite parameters in self.custom

  • post – instructions post installation (see the cnostructor for more help)

  • out_streams – if it is a list, the function will add standard outputs

Returns:

boolean

The options mentioned in parameter options are described here: pip install or setup.py options if you installing a module from github.

Changed in version 1.0: deps is overwritten by self.deps if not None

Changed in version 1.1: On Anaconda (based on function is_conda_distribution), we try conda first before switching to the regular way if it did not work. Exception were changed from Exception to InstallError. Parameter source was added, if None, it is overwritten by self.source. Parameter custom was added, it works the same as source. Parameter post was added. Parameter out_streas added.

source on GitHub

static is_annoying(module_name)

some modules are not available on pipy

source on GitHub

is_installed_local()

checks if a module is installed

source on GitHub

is_installed_local_cmd()

Test the module by running a command line. Does some others verifications for a specific modules such as scipy.

New in version 1.1.

source on GitHub

is_installed_version()

tells if a module is installed

Returns:

boolean

source on GitHub

module_install_preprocess(post)

Run some preprocessing for specific modules

Parameters:

post – dictionary

source on GitHub

run_post_installation(post)

Run instructions post installation

Parameters:

post – dictionary, instructions post installation

Returns:

boolean

Example:

post = dict(
    cmd_python="Scripts\\pywin32_postinstall.py -install")

New in version 1.1.

source on GitHub

unzipfiles(zipf, whereTo)

unzip files from a zip archive

Parameters:
  • zipf – archive

  • whereTo – destination folder

Returns:

list of unzipped files

source on GitHub

update(force_kind=None, force=False, temp_folder='.', log=False, options=None, deps=False, source=None)

Updates the package if necessary, we use pip install <module_name> --upgrade --no-deps,

Parameters:
  • force_kind – overwrite self.kind

  • force – force the installation even if not need to update

  • temp_folder – folder where to download the setup

  • log – display logs or not

  • options – others options to add to the command line (see below) an a list

  • deps – download the dependencies too (only available for pip)

  • source – overwrite the source of the wheel, see get_exewheel_url_link2

Returns:

boolean

The options mentioned in parameter options are described here: pip install or setup.py options if you installing a module from github.

Changed in version 1.1: Parameter source was added, if None, it is overwritten by self.source.

source on GitHub

pymyinstall.installhelper.module_install._filter_pip_out(out)