From 238a0b5dd8abac0ca5eeb2c84f966966dd2fcd7f Mon Sep 17 00:00:00 2001
From: Marcus Schiesser <mail@marcusschiesser.de>
Date: Fri, 26 Jan 2024 16:30:50 +0700
Subject: [PATCH] fix: don't install root package for llamapack examples (as
 there isn't one)

---
 helpers/llama-pack.ts | 2 +-
 helpers/poetry.ts     | 6 ++++--
 helpers/python.ts     | 8 +++++---
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/helpers/llama-pack.ts b/helpers/llama-pack.ts
index 01c26212..f70bc909 100644
--- a/helpers/llama-pack.ts
+++ b/helpers/llama-pack.ts
@@ -86,6 +86,6 @@ export const installLlamapackProject = async ({
   await copyData({ root });
   await installLlamapackExample({ root, llamapack });
   if (postInstallAction !== "none") {
-    installPythonDependencies(root);
+    installPythonDependencies({ noRoot: true });
   }
 };
diff --git a/helpers/poetry.ts b/helpers/poetry.ts
index a42b2be0..fe8759d7 100644
--- a/helpers/poetry.ts
+++ b/helpers/poetry.ts
@@ -10,9 +10,11 @@ export function isPoetryAvailable(): boolean {
   return false;
 }
 
-export function tryPoetryInstall(): boolean {
+export function tryPoetryInstall(noRoot: boolean): boolean {
   try {
-    execSync("poetry install", { stdio: "inherit" });
+    execSync(`poetry install${noRoot ? " --no-root" : ""}`, {
+      stdio: "inherit",
+    });
     return true;
   } catch (_) {}
   return false;
diff --git a/helpers/python.ts b/helpers/python.ts
index 163a2f6b..015e2c26 100644
--- a/helpers/python.ts
+++ b/helpers/python.ts
@@ -92,12 +92,14 @@ export const addDependencies = async (
   }
 };
 
-export const installPythonDependencies = (root: string) => {
+export const installPythonDependencies = (
+  { noRoot }: { noRoot: boolean } = { noRoot: false },
+) => {
   if (isPoetryAvailable()) {
     console.log(
       `Installing python dependencies using poetry. This may take a while...`,
     );
-    const installSuccessful = tryPoetryInstall();
+    const installSuccessful = tryPoetryInstall(noRoot);
     if (!installSuccessful) {
       console.error(
         red("Install failed. Please install dependencies manually."),
@@ -181,6 +183,6 @@ export const installPythonTemplate = async ({
   await addDependencies(root, addOnDependencies);
 
   if (postInstallAction !== "none") {
-    installPythonDependencies(root);
+    installPythonDependencies();
   }
 };
-- 
GitLab