Skip to content

Commit

Permalink
chore: Add done. signal when package installation is completed (#195)
Browse files Browse the repository at this point in the history
* fix: strip extras from package req

micropip.install() doesn't install extras but apparently it *acts like it does*.

* feat: Add indication that installation completed

It was pointed out on Discord that the current message approach
makes it look like the last installation has hung

* fix: micropip.install() installs extras if the main package isn't installed
  • Loading branch information
gadenbuie authored Jan 22, 2025
1 parent 6975f07 commit 6af0f17
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/hooks/usePyodide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,17 @@ async def _install_requirements_from_dir(dir: str) -> None:
extras.update({e.strip() for e in match_extras.group(2).split(",")})
if pkg_name not in micropip.list():
print(f"Installing {req} ...")
req = re.sub(r"#.+$", "", req).strip()
print(f"\\nInstalling {req}...", end=" ", flush=True)
await micropip.install(req)
print("done.", flush=True)
if len(extras) == 0:
continue
else:
# Because micropip.install() doesn't install extras, we have to
# find the package requirements of each extra and install them
# if they aren't already installed.
# Because micropip.install() doesn't install extras if the primary
# package was already installed, we have to find the package
# requirements of each extra and install them manually if needed.
dist = importlib.metadata.distribution(pkg_name)
provided_extras = set(dist.metadata.get_all("Provides-Extra") or [])
Expand All @@ -446,8 +448,9 @@ async def _install_requirements_from_dir(dir: str) -> None:
for extra_req in extra_reqs:
extra_req_name = re.sub(r"([a-zA-Z0-9._,-]+)(.*)", r"\\1", extra_req).strip()
if extra_req_name not in micropip.list():
print(f"Installing {extra_req_name} for {pkg_name}[{extra}]")
print(f"\\nInstalling {extra_req_name} for {pkg_name}[{extra}]...", end=" ", flush = True)
await micropip.install(extra_req_name)
print("done.", flush = True)
async def _load_packages_from_dir(dir: str) -> None:
Expand Down

0 comments on commit 6af0f17

Please sign in to comment.