API

Only the below API should be considered public.

Enthought egg features

EggMetadata class

This models the metadata of an Enthought egg:

metadata = EggMetadata.from_egg("numpy-1.7.1-1.egg")
print(metadata.platform_tag)
class okonomiyaki.file_formats.EggMetadata(raw_name, version, platform, python, abi_tag, platform_abi, dependencies, pkg_info, summary, metadata_version=None)[source]

Enthought egg metadata for format 1.x.

HIGHEST_SUPPORTED_METADATA_VERSION = MetadataVersion(1, 4)

Highest supported metadata version (as a MetadataVersion object).

If the parsed metadata is higher, it will not be possible to write back the metadata. If the parsed metadata version is not compatible (different major version), then parsing will raise an UnsupportedMetadata exception as well.

abi = None

The ABI tag, following the PEP425 format, except that no ABI is sorted as None.

build

The build number.

dump(path)[source]

Write the metadata to the given path as a metadata egg.

A metadata egg is a zipfile using the same structured as an egg, except that it only contains metadata.

Parameters:path (str) – The path to write the zipped metadata into.
egg_basename

The egg “base name”, i.e. the name part of the egg filename.

egg_name

The egg filename.

classmethod from_egg(path_or_file, strict=True)[source]

Create a EggMetadata instance from an existing Enthought egg.

path: str or file-like object.
If a string, understood as the path to the egg. Otherwise, understood as a zipfile-like object.
strict: bool
If True, will fail if metadata cannot be decoded correctly (e.g. unicode errors in EGG-INFO/PKG-INFO). If false, will ignore those errors, at the risk of data loss.
classmethod from_egg_metadata(egg_metadata, **kw)[source]

Utility ctor to create a new EggMetadata instance from an existing one, potentially updating some metadata.

Any keyword argument (except egg_metadata) is understood as an argument to EggMetadata.__init__.

egg_metadata: EggMetadata

is_strictly_supported

Returns True if the given metadata_version is fully supported.

A metadata_version is fully supported iff:
  • metadata_version.major == EggMetadata.HIGHEST_SUPPORTED_METADATA_VERSION.major
  • and metadata_version.minor <= EggMetadata.HIGHEST_SUPPORTED_METADATA_VERSION.minor
metadata_version = None

The version format of the underlying metadata.

name

The package name.

platform = None

The platform, as a Platform instance.

platform_tag

Platform tag following PEP425, except that no platform is represented as None and not ‘any’.

python = None

The python implementation.

runtime_dependencies = None

List of runtime dependencies (as strings).

summary = None

The summary string.

version = None

The version, as an EnpkgVersion instance.

EggBuilder class

This is a class to build Enthought eggs from an install tree

class okonomiyaki.file_formats.EggBuilder(egg_metadata, compress=True, cwd=None)[source]

Class to build eggs from an install tree. This is mostly useful to build Enthought eggs for non-python packages (C/C++ libraries, etc…)

add_data(data, archive_name, chmod=420)

Write the given data as the given archive name.

add_file(path, archive_prefix='')

Add the given file to the egg, under the given archive prefix.

add_file_as(path, archive_name)

Add the given file to the egg, under the given archive name.

add_iterator(iterator)

Add the files specified by the given iterator.

iterator: iterator
An iterator yielding (path, arcname) pairs.
add_tree(directory, archive_prefix='')

Add the given directory to the egg, under the given archive_prefix.

directory: path
A path to a directory. Every file in this directory will be included, recursively.
commit()

Commit the metadata, and close the file.

EggRewriter class

This is a class to build Enthought eggs from an existing setuptools egg.

class okonomiyaki.file_formats.EggRewriter(egg_metadata, egg, compress=True, cwd=None, rename=None, accept=None, allow_overwrite=False)[source]

Class to create Enthought eggs from existing setuptools eggs.

add_data(data, archive_name, chmod=420)

Write the given data as the given archive name.

add_file(path, archive_prefix='')

Add the given file to the egg, under the given archive prefix.

add_file_as(path, archive_name)

Add the given file to the egg, under the given archive name.

add_iterator(iterator)

Add the files specified by the given iterator.

iterator: iterator
An iterator yielding (path, arcname) pairs.
add_tree(directory, archive_prefix='')

Add the given directory to the egg, under the given archive_prefix.

directory: path
A path to a directory. Every file in this directory will be included, recursively.

Runtimes

Runtime metadata factory

This class allows you to parse edm runtime format, through its factory class methods.

class okonomiyaki.runtimes.IRuntimeMetadata(metadata_version)[source]

The metadata of a runtime package (i.e. the actual zipfile containing the runtime code).

classmethod factory_from_path(path)[source]

Creates a metadata instance from the given path.

The created instance’s class will be detected dynamically from the metadata file content.

filename

The filename a runtime with this set of metadata.

Platforms representations

The main API is EPDPlatform. You can either create an explicit platform, or try to guess the platform from the running system:

platform = EPDPlatform.from_epd_string("rh5-32")
platform = EPDPlatform.from_running_system()

One can access details through EPDPlatform instances’ attributes.

class okonomiyaki.platforms.EPDPlatform(platform)[source]

An sane Canopy/EPD platform representation.

Example:

epd_platform = EPDPlatform.from_epd_string("rh5-32")
assert epd.name == "rh5"
assert epd.arch_bits == "32"
assert epd.arch == "x86"
arch_bits

The number of bits (as a string) of this epd platform.

classmethod from_epd_string(s)[source]

Create a new instance from an epd platform string (e.g. ‘win-32’)

DEPRECATED: use from_string instead.

classmethod from_running_python()[source]

Attempt to create an EPDPlatform instance by guessing the running python. May raise an OkonomiyakiError exception

classmethod from_running_system(arch_name=None)[source]

Attempt to create an EPDPlatform instance by guessing the running platform. May raise an OkonomiyakiError exception

arch_name: str, None
If given, must be a valid architecture string (e.g. ‘x86’). If None, will be guessed from the running platform.
classmethod from_string(s)[source]

Create a new instance from an epd platform string (e.g. ‘win-32’)

Note: new, more explicit architecture names are also supported, e.g. ‘win-x86’ or ‘win-x86_64’ are supported.

platform = None

Main name of the platform (e.g. ‘rh5’)

Generic platform representations are available through the Platform class.

class okonomiyaki.platforms.Platform(os_kind, name_kind, family_kind, release, arch, machine)[source]

An generic platform representation.

arch = None

Actual architecture. The architecture is guessed from the running python.

family_kind = None

The ‘kind’ of platforms. For example, both debian and ubuntu distributions share the same kind, ‘debian’.

classmethod from_running_python()[source]

Guess the platform, using the running python to guess the architecture.

classmethod from_running_system(arch_string=None)[source]

Guess the platform, with an optional architecture string.

arch_string: str, None
If given, should be a valid architecture name (e.g. ‘x86’)
machine = None

The machine. This is the CPU architecture (e.g. for a 32 bits python running on 64 bits Intel OS, machine will be an x86_64 arch, whereas arch will be an ‘x86’ arch)

name_kind = None

The most specific platform description

os_kind = None

The most generic OS description

release = None

The release string. May be an empty string

Version representations

Each class has a from_string constructor to build the corresponding object from its string representation. Those classes are designed to compare versions between them (intra class, you obviously cannot compare a version from one kind to a version of a different kind).

To manipulate versions in Enthought’ eggs, you should use EnpkgVersion.

class okonomiyaki.versions.PEP440Version(epoch, nums, pre, post, dev, local)[source]

A PEP440-compliant version object.

Note: replacements are not supported yet.

normalized_string

‘normalized’ string, i.e. 0 in the numerical part are stripped.

class okonomiyaki.versions.EnpkgVersion(upstream, build)[source]
classmethod from_string(version_string)[source]

Creates a new EnpkgVersion from its string representation.

Parameters:version_string (str) – the version string.
classmethod from_upstream_and_build(upstream, build)[source]

Creates a new EnpkgVersion from the upstream string and the build number.

Parameters:
  • upstream (str) – The upstream version (e.g. ‘1.3.0’)
  • build (int) – The build number
class okonomiyaki.versions.SemanticVersion(major, minor, patch, pre_release=None, build=None)[source]

‘Semver’ 2.0 implementation.

This class takes care of parsing and comparing semver objects.

class okonomiyaki.versions.MetadataVersion(major, minor)[source]

A simple MAJOR.MINOR version object for metadata versioning.

classmethod from_string(s)[source]

Creates a new instance from a version string.