rez.package_copy#

rez.package_copy.copy_package(package, dest_repository, variants=None, shallow=False, dest_name=None, dest_version=None, overwrite=False, force=False, follow_symlinks=False, dry_run=False, keep_timestamp=False, skip_payload=False, overrides=None, verbose=False)#

Copy a package from one package repository to another.

This copies the package definition and payload. The package can also be re-named and/or re-versioned using the dest_name and dest_version args.

The result is a dict describing which package variants were and were not copied. For example:

{
    "copied": [
        (`Variant`, `Variant`)
    ],
    "skipped": [
        (`Variant`, `Variant`)
    ]
}

Each 2-tuple in the ‘copied’ or ‘skipped’ list contains the source and destination variant respectively. In the ‘skipped’ list, the source variant is the variant that was NOT copied, and the dest variant is the existing target variant that caused the source not to be copied. Skipped variants will only be present when overwrite is False.

Note

Whether or not a package can be copied is determined by its relocatable attribute (see the default_relocatable config setting for more details). An attempt to copy a non-relocatable package will fail. You can override this behaviour with the force argument.

Parameters:
  • package (Package) – Package to copy.

  • dest_repository (PackageRepository or str) – The package repository, or a package repository path, to copy the package into.

  • variants (list[int]) – Indexes of variants to build, or all if None.

  • shallow (bool) – If True, symlinks of each variant’s root directory are created, rather than the payload being copied.

  • dest_name (str) – If provided, copy the package to a new package name.

  • dest_version (str or Version) – If provided, copy the package to a new version.

  • overwrite (bool) – Overwrite variants if they already exist in the destination package. In this case, the existing payload is removed before the new payload is copied.

  • force (bool) – Copy the package regardless of its relocatable attribute. Use at your own risk (there is no guarantee the resulting package will be functional).

  • follow_symlinks (bool) – Follow symlinks when copying package payload, rather than copying the symlinks themselves.

  • keep_timestamp (bool) – By default, a newly copied package will get a new timestamp (because that’s when it was added to the target repo). By setting this option to True, the original package’s timestamp is kept intact. Note that this will have no effect if variant(s) are copied into an existing package.

  • skip_payload (bool) – If True, do not copy the package payload.

  • overrides (dict) – See PackageRepository.install_variant().

  • verbose (bool) – Verbose mode.

  • dry_run (bool) – Dry run mode. Dest variants in the result will be None in this case.

Returns:

See comments above.

Return type:

Dict