API documentation

Configuration

class enstaller.config.Configuration(**kw)[source]
api_url[source]

Url to hit to get user information on api.e.com.

auth[source]

The auth object that may be passed to Session.authenticate

Returns:the auth instance, or None is configured.
Return type:IAuth or None
autoupdate[source]

Whether enpkg should attempt updating itself.

filename[source]

The filename this configuration was created from. May be None if the configuration was not created from a file.

classmethod from_file(filename)[source]

Create a new Configuration instance from the given file.

filename: str or file-like object
If a string, is understood as a filename to open. Understood as a file-like object otherwise.
indexed_repositories[source]

List of (old-style) repositories. Only actually used when use_webservice is False.

indices[source]

Returns a list of pair (index_url, store_location) for this given configuration.

Takes into account webservice/no webservice and pypi True/False

max_retries[source]

Max attempts to retry an http connection or re-fetching data whose checksum failed.

noapp[source]

Ignore appinst entries.

prefix[source]

Prefix in which enpkg operates.

proxy[source]

A ProxyInfo instance or None if no proxy is configured.

proxy_dict[source]

A dictionary <scheme>:<proxy_string> that can be used as the proxies argument for requests.

repository_cache[source]

Absolute path where eggs will be cached.

set_repositories_from_names(names)[source]

Set repositories from their names alone, e.g. ‘enthought/free’.

Parameters:names (list) – List of repository names
store_kind[source]

Store kind (brood, legacy canopy, old-repo style).

store_url[source]

The store url to hit for indices and eggs.

update(**kw)[source]

Set configuration attributes given as keyword arguments.

use_pypi[source]

Whether to load pypi repositories (in webservice mode).

use_webservice[source]

Whether to use canopy legacy or not.

verify_ssl[source]

Whether to verify SSL CA or not.

webservice_entry_point[source]

Whether to fetch indices and data (in webservice mode).

write(filename)[source]

Write this configuration to the given filename.

Parameters:filename (str) – The path of the written file.
enstaller.config.write_default_config(filename)[source]

Write a default configuration file at the given location.

Will raise an exception if a file already exists.

Parameters:filename (str) – The location to write to.

Repository

class enstaller.repository.Repository(packages=None)[source]

A Repository is a set of package, and knows about which package it contains.

delete_package(package_metadata)[source]

Remove the given package.

Removing a non-existent package is an error.

Parameters:package_metadata (PackageMetadata) – The package to remove
find_latest_package(name)[source]

Returns the latest package with the given name.

Parameters:name (str) – The package’s name
Returns:package (PackageMetadata)
find_package(name, version)[source]

Search for the first match of a package with the given name and version.

Parameters:
  • name (str) – The package name to look for.
  • version (str) – The full version string to look for (e.g. ‘1.8.0-1’).
Returns:

package (RepositoryPackageMetadata) – The corresponding metadata.

find_package_from_requirement(requirement)[source]

Search for latest package matching the given requirement.

Parameters:requirement (Requirement) – The requirement to match for.
Returns:package (RepositoryPackageMetadata) – The corresponding metadata.
find_packages(name, version=None)[source]

Returns a list of package metadata with the given name and version

Parameters:
  • name (str) – The package’s name
  • version (str or None) – If not None, the version to look for
Returns:

packages (iterable) – Iterable of RepositoryPackageMetadata-like (order is unspecified)

find_sorted_packages(name)[source]

Returns a list of package metadata with the given name and version, sorted from lowest to highest version (when possible).

Parameters:name (str) – The package’s name
Returns:packages (iterable) – Iterable of RepositoryPackageMetadata.
has_package(package_metadata)[source]

Returns True if the given package is available in this repository

Parameters:package_metadata (PackageMetadata) – The package to look for.
Returns:ret (bool) – True if the package is in the repository, false otherwise.
iter_most_recent_packages()[source]

Iter over each package of the repository, but only the most recent version of a given package

Returns:packages (iterable) – Iterable of the corresponding RepositoryPackageMetadata-like instances.
iter_packages()[source]

Iter over each package of the repository

Returns:packages (iterable) – Iterable of RepositoryPackageMetadata-like.

Session

class enstaller.session.Session(authenticator, cache_directory, proxies=None, verify=True, max_retries=0)[source]

Simple class to handle http session management

It also ensures connection settings such as proxy, SSL CA certification, etc... are handled consistently).

Parameters

authenticator : IAuthManager
An authenticator instance
cache_directory : str
A writeable directory to cache data and eggs.
proxies : dict
A proxy dict as expected by requests (and provided by Configuration.proxy_dict).
verify : bool
If True, SSL CA are verified (default).
classmethod authenticated_from_configuration(configuration)[source]

Create a new authenticated session from a configuration.

Parameters:configuration (Configuration) – The configuration to use.
download(url, target=None)[source]

Safely download the content at the give url.

Safely here is understood as not leaving stalled content if the download fails or is canceled. It uses streaming as so not to use too much memory.

classmethod from_configuration(configuration)[source]

Create a new session from a configuration.

Parameters:configuration (Configuration) – The configuration to use.