Skip to content

Commit 1ca9746

Browse files
committed
feat: initial commit
1 parent bbb91b8 commit 1ca9746

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

scripts/setup-git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def setup_git(path: Path, github_user: str, repo_name: str) -> None:
3535
check_dependencies(path=path, dependencies=["git"])
3636

3737
for command in commands:
38-
subprocess.run(command, cwd=path, capture_output=True)
38+
subprocess.run(command, cwd=path, stderr=subprocess.STDOUT)
3939

4040

4141
def get_parser() -> argparse.ArgumentParser:

scripts/setup-venv.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
Since this a first time setup script, we intentionally only use builtin Python dependencies.
44
"""
55
import argparse
6+
import shutil
67
import subprocess
78
from pathlib import Path
89

910
from util import check_dependencies
1011
from util import existing_dir
12+
from util import remove_readonly
1113

1214

1315
def main() -> None:
@@ -49,6 +51,10 @@ def setup_venv(path: Path, python_version: str) -> None:
4951
]
5052
check_dependencies(path=path, dependencies=["uv"])
5153

54+
venv_path: Path = path / ".venv"
55+
if venv_path.exists():
56+
shutil.rmtree(venv_path, onerror=remove_readonly)
57+
5258
for command in commands:
5359
subprocess.run(command, cwd=path, capture_output=True)
5460

scripts/util.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"""Module containing util"""
22
import argparse
3+
import os
4+
import stat
35
import subprocess
46
from pathlib import Path
7+
from typing import Any
8+
from typing import Callable
59

610

711
class MissingDependencyError(Exception):
@@ -32,3 +36,12 @@ def existing_dir(value: str) -> Path:
3236
raise argparse.ArgumentTypeError(f"{path} is not a directory.")
3337

3438
return path
39+
40+
41+
def remove_readonly(func: Callable[[str], Any], path: str, _: Any) -> None:
42+
"""Clears the readonly bit and attempts to call the provided function.
43+
44+
This is passed to shutil.rmtree as the onerror kwarg.
45+
"""
46+
os.chmod(path, stat.S_IWRITE)
47+
func(path)

0 commit comments

Comments
 (0)