Skip to content

Commit

Permalink
Wait for repodata_record.json to appear
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Feb 26, 2023
1 parent 2adbb31 commit e83de6e
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions conda_lock/conda_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,41 @@ def print_pkgs_dirs_contents(pkgs_dirs: List[pathlib.Path]) -> None:
print(entry)


def get_repodata_record(
pkgs_dirs: List[pathlib.Path], dist_name: str
) -> Optional[FetchAction]:
import time

for pkgs_dir in pkgs_dirs:
record = pkgs_dir / dist_name / "info" / "repodata_record.json"
if record.exists():
with open(record) as f:
repodata: FetchAction = json.load(f)
return repodata
print(f"Could not find repodata_record.json for {dist_name} in {pkgs_dirs}")
for _ in range(200):
for pkgs_dir in pkgs_dirs:
for path in pkgs_dir.glob(f"{dist_name}*"):
if path.is_file():
print(f"File: {path}")
elif path.is_dir():
print(f"Directory: {path}")
if path.name == dist_name:
print("Contents:")
for entry in path.iterdir():
print(f" {entry}")
if entry.name == "info":
for info_entry in entry.iterdir():
print(f" {info_entry}")
if info_entry.name == "repodata_record.json":
with open(info_entry) as f:
print(f.read())
print("We would have been able to use this.")
return None
time.sleep(0.1)
return None


def _reconstruct_fetch_actions(
conda: PathLike,
platform: str,
Expand Down Expand Up @@ -259,18 +294,8 @@ def _reconstruct_fetch_actions(

for link_pkg_name in link_only_names:
link_action = link_actions[link_pkg_name]
for pkgs_dir in pkgs_dirs:
record = (
pkgs_dir
/ link_action["dist_name"]
/ "info"
/ "repodata_record.json"
)
if record.exists():
with open(record) as f:
repodata: FetchAction = json.load(f)
break
else:
repodata = get_repodata_record(pkgs_dirs, link_action["dist_name"])
if repodata is None:
print(f"\n\n---\n{link_pkg_name=}\n\n---\n{link_action=}")
print_pkgs_dirs_contents(pkgs_dirs)
raise FileNotFoundError(
Expand Down

0 comments on commit e83de6e

Please sign in to comment.