Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 563 #566

Merged
merged 2 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 64 additions & 32 deletions src/rez/package_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def finalize():
dest_pkg_repo=dest_pkg_repo,
shallow=shallow,
follow_symlinks=follow_symlinks,
overrides=overrides
overrides=overrides,
verbose=verbose
)

# construct overrides
Expand All @@ -213,7 +214,7 @@ def finalize():


def _copy_variant_payload(src_variant, dest_pkg_repo, shallow=False,
follow_symlinks=False, overrides=None):
follow_symlinks=False, overrides=None, verbose=False):
# Get payload path of source variant. For some types (eg from a "memory"
# type repo) there may not be a root.
#
Expand Down Expand Up @@ -243,7 +244,7 @@ def _copy_variant_payload(src_variant, dest_pkg_repo, shallow=False,
variant_install_path = os.path.join(variant_install_path,
src_variant.subpath)

# perform the copy/symlinking
# get ready for copy/symlinking; create variant install path
copy_func = partial(replacing_copy,
follow_symlinks=follow_symlinks)

Expand All @@ -252,38 +253,69 @@ def _copy_variant_payload(src_variant, dest_pkg_repo, shallow=False,
else:
maybe_symlink = copy_func

safe_makedirs(variant_install_path)

# determine files not to copy
skip_files = []

if src_variant.subpath:
# symlink/copy the last install dir to the variant root
safe_makedirs(os.path.dirname(variant_install_path))
maybe_symlink(variant_root, variant_install_path)
# Detect overlapped variants. This is the case where one variant subpath
# might be A, and another is A/B. We must ensure that A/B is not created
# as a symlink during shallow install of variant A - that would then
# cause A/B payload to be installed back into original package, possibly
# corrupting it.
#
# Here we detect this case, and create a list of dirs not to copy/link,
# because they are in fact a subpath dir for another variant.
#
skip_files.extend(_get_other_variant_dirs(src_variant))
else:
safe_makedirs(variant_install_path)
# just skip package definition file
for name in config.plugins.package_repository.filesystem.package_filenames:
for fmt in (FileFormat.py, FileFormat.yaml):
filename = name + '.' + fmt.extension
skip_files.append(filename)

# Symlink/copy all files and dirs within the null variant, except
# for the package definition itself.
#
for name in os.listdir(variant_root):
is_pkg_defn = False

# skip package definition file
name_ = os.path.splitext(name)[0]
if name_ in config.plugins.package_repository.filesystem.package_filenames:
for fmt in (FileFormat.py, FileFormat.yaml):
filename = name_ + '.' + fmt.extension
if name == filename:
is_pkg_defn = True
break

if is_pkg_defn:
continue

src_path = os.path.join(variant_root, name)
dest_path = os.path.join(variant_install_path, name)

if os.path.islink(src_path):
copy_func(src_path, dest_path)
else:
maybe_symlink(src_path, dest_path)
# copy/link all topmost files within the variant root
for name in os.listdir(variant_root):
if name in skip_files:
filepath = os.path.join(variant_root, name)

if verbose:
if src_variant.subpath:
msg = ("Did not copy %s - this is part of an "
"overlapping variant's root path.")
else:
msg = "Did not copy package definition file %s"

print_info(msg, filepath)

continue

src_path = os.path.join(variant_root, name)
dest_path = os.path.join(variant_install_path, name)

if os.path.islink(src_path):
copy_func(src_path, dest_path)
else:
maybe_symlink(src_path, dest_path)


def _get_other_variant_dirs(src_variant):
package = src_variant.parent
dirs = set()

# find other variants that overlap src_variant and have deeper subpath
for variant in package.iter_variants():
if variant.index == src_variant.index:
continue

if variant.root.startswith(src_variant.root + os.path.sep):
relpath = os.path.relpath(variant.root, src_variant.root)
topmost_dir = relpath.split(os.path.sep)[0]
dirs.add(topmost_dir)

return list(dirs)


def _copy_package_include_modules(src_package, dest_pkg_repo, overrides=None):
Expand Down
2 changes: 1 addition & 1 deletion src/rez/utils/_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@


# Update this value to version up Rez. Do not place anything else in this file.
_rez_version = "2.26.4"
_rez_version = "2.26.5"

try:
from rez.vendor.version.version import Version
Expand Down