Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

Fix cookiecutter docker-compose generation on Windows

LearningCircuit8074a7733a40
diff --git a/cookiecutter-docker/hooks/post_gen_project.py b/cookiecutter-docker/hooks/post_gen_project.py
index 1ae53867d4..d5bb1c7fda 100644
--- a/cookiecutter-docker/hooks/post_gen_project.py
+++ b/cookiecutter-docker/hooks/post_gen_project.py
@@ -2,20 +2,55 @@
Extracts the compose file from the cookiecutter directory.
"""
+import os
import shutil
+import time
from pathlib import Path
COMPOSE_FILE_NAME = "docker-compose.{{cookiecutter.config_name}}.yml"
+def rmtree_with_retry(
+ path: Path, max_retries: int = 5, initial_delay: float = 0.1
+):
+ """
+ Remove a directory tree with retry logic for Windows.
+
+ On Windows, files may be temporarily locked by antivirus software,
+ Windows Search indexing, or other processes. This function retries
+ the removal with exponential backoff.
+ """
+ delay = initial_delay
+ last_error = None
+
+ for attempt in range(max_retries):
+ try:
+ shutil.rmtree(path)
+ return # Success
+ except PermissionError as e:
+ last_error = e
+ if attempt < max_retries - 1:
+ time.sleep(delay)
+ delay *= 2 # Exponential backoff
+
+ # If we get here, all retries failed
+ raise last_error
+
+
def main():
# Move the compose file one directory up.
compose_path = Path(COMPOSE_FILE_NAME)
output_dir = compose_path.parent.absolute()
- compose_path.rename(output_dir.parent / COMPOSE_FILE_NAME)
+ dest_path = output_dir.parent / COMPOSE_FILE_NAME
+
+ # Use shutil.move instead of Path.rename for better cross-platform support
+ shutil.move(str(compose_path), str(dest_path))
- # Delete the directory.
- shutil.rmtree(output_dir)
+ # Delete the directory with retry logic for Windows file locking.
+ if os.name == "nt":
+ rmtree_with_retry(output_dir)
+ else:
+ shutil.rmtree(output_dir)
if __name__ == "__main__":
diff --git a/cookiecutter-docker/hooks/pre_prompt.py b/cookiecutter-docker/hooks/pre_prompt.py
index 4b174cb04c..6c4e53fdf8 100644
--- a/cookiecutter-docker/hooks/pre_prompt.py
+++ b/cookiecutter-docker/hooks/pre_prompt.py
@@ -29,10 +29,9 @@ def config_ollama(context: Dict[str, Any]) -> None:
context["_ollama_model"] = ollama_model
-def check_gpu(context: Dict[str, Any]) -> None:
+def check_gpu_linux(context: Dict[str, Any]) -> None:
"""
- Check if the system has an NVIDIA or AMD GPU and set flags in the
- context.
+ Check if the system has an NVIDIA or AMD GPU on Linux.
Args:
context: The context dictionary to update with GPU information.
@@ -57,14 +56,43 @@ def check_gpu(context: Dict[str, Any]) -> None:
context["enable_gpu"] = False
+def check_gpu_windows(context: Dict[str, Any]) -> None:
+ """
+ Check if the system has an NVIDIA or AMD GPU on Windows.
+
+ Args:
+ context: The context dictionary to update with GPU information.
+
+ """
+ gpu_info = run_command("wmic path win32_VideoController get name")
+
+ if "NVIDIA" in gpu_info.upper():
+ print("Detected an Nvidia GPU.")
+ context["_nvidia_gpu"] = True
+ context["_amd_gpu"] = False
+ context["enable_gpu"] = True
+ elif "AMD" in gpu_info.upper() or "RADEON" in gpu_info.upper():
+ print("Detected an AMD GPU.")
+ context["_amd_gpu"] = True
+ context["_nvidia_gpu"] = False
+ context["enable_gpu"] = True
+ else:
+ print("Did not detect any GPU.")
+ context["_nvidia_gpu"] = False
+ context["_amd_gpu"] = False
+ context["enable_gpu"] = False
+
+
def main() -> None:
# Load the context.
with open("cookiecutter.json", "r") as config:
context = json.load(config)
- # Check GPU information and update the context only if running on Linux.
+ # Check GPU information based on the operating system.
if os.name == "posix" and os.uname().sysname == "Linux":
- check_gpu(context)
+ check_gpu_linux(context)
+ elif os.name == "nt":
+ check_gpu_windows(context)
# Ollama-specific config.
config_ollama(context)