Skip to content

Commit ba9e2fe

Browse files
JonZeollaclaude
andcommitted
fix: only rename top-level template dir in Windows zip extraction
The zip extraction was replacing ALL {{cookiecutter.*}} directory names with {{cookiecutter.project_name}}, including nested ones like {{cookiecutter.project_slug}}. This caused src/replace_me/ to become src/replace-me/ on Windows, breaking Python imports. Only rename the top-level template dir (which has NTFS-illegal pipe and quote chars). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c3c3bfb commit ba9e2fe

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,16 @@ jobs:
145145
zf, dest = zipfile.ZipFile(sys.argv[1]), sys.argv[2]
146146
for info in zf.infolist():
147147
parts = info.filename.split('/')
148-
safe = [('{{cookiecutter.project_name}}' if '{{cookiecutter.' in p else p) for p in parts]
148+
# Only rename the top-level template dir (index 1) which has
149+
# NTFS-illegal chars (pipe, quotes). Nested cookiecutter dirs
150+
# like {{cookiecutter.project_slug}} are NTFS-safe and must be
151+
# preserved so cookiecutter renders them correctly.
152+
safe = []
153+
for i, p in enumerate(parts):
154+
if i == 1 and '{{cookiecutter.' in p:
155+
safe.append('{{cookiecutter.project_name}}')
156+
else:
157+
safe.append(p)
149158
target = os.path.join(dest, *[s for s in safe if s])
150159
if info.is_dir():
151160
os.makedirs(target, exist_ok=True)

{{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ vars:
1616
RUN_SCRIPT: 'uv run --frozen'
1717
SCRIPTS_DIR: 'scripts'
1818
VERSION:
19-
sh: "{{ '{{.RUN_SCRIPT}}' }} python -c \"import sys,os;d=os.path.join(os.getcwd(),'src');print(f'DEBUG cwd={os.getcwd()} src_contents={os.listdir(d)} syspath0={sys.path[:3]}',file=sys.stderr);sys.path.insert(0,d);from {{ '{{.PROJECT_SLUG}}' }} import __version__;print(__version__)\""
19+
sh: "{{ '{{.RUN_SCRIPT}}' }} python -c \"import sys; sys.path.insert(0, 'src'); from {{ '{{.PROJECT_SLUG}}' }} import __version__; print(__version__)\""
2020
LOCAL_PLATFORM:
2121
sh: "bash {{ '{{.SCRIPTS_DIR}}' }}/get_platform.sh"
2222
# Use PLATFORM if specified, otherwise use LOCAL_PLATFORM

0 commit comments

Comments
 (0)