Skip to content

Commit

Permalink
Store lockfile-relative sources in lockfiles, unless on different drives
Browse files Browse the repository at this point in the history
* Fixes conda#229, relying on what introduced in conda#204 for the input metadata, by explicitly handling only the case of different drives for keeping absolute paths, addressing conda#175.
  • Loading branch information
riccardoporreca committed Feb 4, 2023
1 parent 1c3f987 commit bc9d2ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,15 +809,15 @@ def create_lockfile_from_spec(
for dep in deps:
locked[(dep.manager, dep.name, dep.platform)] = dep

spec_sources: Dict[str, pathlib.Path] = {}
meta_sources: Dict[str, pathlib.Path] = {}
for source in spec.sources:
try:
path = relative_path(lockfile_path.parent, source)
except ValueError as e:
if "Paths don't have the same drive" not in str(e):
raise e
path = str(source.resolve())
spec_sources[path] = source
meta_sources[path] = source

if MetadataOption.TimeStamp in metadata_choices:
time_metadata = TimeMeta.create()
Expand All @@ -842,10 +842,10 @@ def create_lockfile_from_spec(

if metadata_choices & {MetadataOption.InputSha, MetadataOption.InputMd5}:
inputs_metadata: Optional[Dict[str, InputMeta]] = {
relative_path: InputMeta.create(
meta_src: InputMeta.create(
metadata_choices=metadata_choices, src_file=src_file
)
for relative_path, src_file in spec_sources.items()
for meta_src, src_file in meta_sources.items()
}
else:
inputs_metadata = None
Expand All @@ -858,7 +858,7 @@ def create_lockfile_from_spec(
content_hash=spec.content_hash(),
channels=[c for c in spec.channels],
platforms=spec.platforms,
sources=[str(source.resolve()) for source in spec.sources],
sources=list(meta_sources.keys()),
git_metadata=git_metadata,
time_metadata=time_metadata,
inputs_metadata=inputs_metadata,
Expand Down

0 comments on commit bc9d2ac

Please sign in to comment.