Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: poetry list packages (#2927)

Akshay Agrawala29755c909ae
diff --git a/marimo/_runtime/packages/pypi_package_manager.py b/marimo/_runtime/packages/pypi_package_manager.py
index a44d3c1f5b..fd51b309db 100644
--- a/marimo/_runtime/packages/pypi_package_manager.py
+++ b/marimo/_runtime/packages/pypi_package_manager.py
@@ -222,6 +222,31 @@ class PoetryPackageManager(PypiPackageManager):
["poetry", "remove", "--no-interaction", *split_packages(package)]
)
+ def _list_packages_from_cmd(
+ self, cmd: List[str]
+ ) -> List[PackageDescription]:
+ if not self.is_manager_installed():
+ return []
+ proc = subprocess.run(cmd, capture_output=True, text=True)
+ if proc.returncode != 0:
+ return []
+
+ # Each line in package_lines is of the form
+ # package_name version_string some more arbitrary text
+ #
+ # For each line, extract the package_name and version_string, ignoring
+ # the rest of the text.
+ package_lines = proc.stdout.splitlines()
+ packages = []
+ for line in package_lines:
+ parts = line.split()
+ if len(parts) < 2:
+ continue
+ packages.append(
+ PackageDescription(name=parts[0], version=parts[1])
+ )
+ return packages
+
def list_packages(self) -> List[PackageDescription]:
- cmd = ["poetry", "show", "--no-dev", "--format=json"]
+ cmd = ["poetry", "show", "--no-dev"]
return self._list_packages_from_cmd(cmd)