xpybuild.targets.archive

Targets relating to creating and unpacking archives such as .\zip, .tar.gz.

Tarball

class xpybuild.targets.archive.Tarball(archive, inputs)[source]

Bases: xpybuild.basetarget.BaseTarget

Target that creates a .tar.gz archive from a set of input files.

Parameters
  • archive – The archive to be created, which should end with .tar.gz.

  • inputs – The files (usually pathsets) to be included in the archive.

Zip

class xpybuild.targets.archive.Zip(archive, inputs)[source]

Bases: xpybuild.basetarget.BaseTarget

Target that creates a .zip archive from a set of input files.

Parameters
  • archive – The archive to be created, ending with .zip.

  • inputs – The files (usually pathsets) to be included in the archive.

Unpack

class xpybuild.targets.archive.Unpack(dest, archives)[source]

Bases: xpybuild.basetarget.BaseTarget

Target that creates a new directory containing the unpacked contents of one or more archives of one of these types: .zip .jar .war .tar.gz .tar.bz2 .tar.

The parent directory will be created if it doesn’t exist already.

Parameters
  • dest – the output directory (ending with a “/”). Never specify a dest directory that is also written to by another target (e.g. do not specify a build ‘output’ directory here).

  • archives – the input archives to be unpacked, which may be any combination of strings, PathSets, FilteredArchiveContents and lists of these. If these PathSets include mapping information, this will be used to define where (under the dest directory) each file from within that archive is copied (but cannot be used to change the archive-relative path of each item).

For advanced cases, FilteredArchiveContents can be used to provide customized mapping and filtering of the archive contents, including manipulation of the destinations encoded within the archive itself.

FilteredArchiveContents

class xpybuild.targets.archive.FilteredArchiveContents(archivePath, includes=None, excludes=None, destMapper=None)[source]

Bases: object

Object representing an archive to be passed to the Unpack target, with support for filtering which files are included/excluded, and per-item destination mapping.

Parameters
  • archivePath – The archive to unpack; either a string or a singleton PathSet

  • destMapper – A functor that takes a (context, destPath) where destPath is an archive-relative path (guaranteed to contain / not ), and returns the desired destination relative path string. The functor should have a deterministic and user-friendly __str__ implementation.

  • includes – a list of include patterns (if provided excludes all non-matching files)

  • excludes – a list of exclude patterns (processed after includes)

getDependency()[source]

Return the dependency representing this archive (unexpanded and unresolved string, or PathSet).

getResolvedPath(context)[source]

Return the fully resolved archive path.

isIncluded(context, path)[source]

Decides whether the specified path within the archive should be unpacked, based on the include/exclude filters

Parameters

path – a relative path within the archive