Skip to content

Commit ef3a74d

Browse files
authored
Add Windows support (closes #8)
1 parent 6c41965 commit ef3a74d

5 files changed

Lines changed: 21 additions & 14 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ on:
1010
jobs:
1111
build:
1212

13-
runs-on: ubuntu-latest
13+
runs-on: ${{ matrix.os }}
1414
strategy:
1515
fail-fast: false
1616
matrix:
17+
os: [ubuntu-latest, windows-latest]
1718
python-version: [3.11, 3.12, 3.13, 3.14]
1819

1920
steps:

src/makeapp/appmaker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def __init__(
113113

114114
# Support for user-supplied template directories.
115115
for template in templates_to_use or []:
116-
if '/' in template:
116+
if os.sep in template:
117117
parent = str(Path(template).parent)
118118
if parent not in search_paths:
119119
search_paths.append(parent)
@@ -302,6 +302,7 @@ def rollout(
302302
:param remote_push: Whether to push to remote.
303303
304304
"""
305+
dest = os.path.abspath(dest)
305306
self.logger.info(f'Application target path: {dest}')
306307

307308
# Make remote available for hooks.

src/makeapp/apptemplate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,12 @@ def get_files(self) -> dict[str, 'TemplateFile']:
120120

121121
full_path = os.path.join(path, fname)
122122

123-
rel_path = full_path.replace(templates_path, '').lstrip('/')
123+
rel_path = os.path.relpath(full_path, templates_path)
124124

125125
template_file = TemplateFile(
126126
template=self,
127127
path_full=full_path,
128-
path_rel=rel_path,
128+
path_rel=rel_path.replace(os.sep, '/'),
129129
)
130130

131131
rel_path = rel_path.replace(maker.package_dir_marker, maker.settings['package_name'])
@@ -174,9 +174,9 @@ def _find(cls, name_or_path: str, search_paths: tuple[str, ...]) -> tuple[str, s
174174
175175
"""
176176
for supposed_path in search_paths:
177-
if '/' in supposed_path and os.path.exists(supposed_path):
177+
if os.sep in supposed_path and os.path.exists(supposed_path):
178178
path = str(os.path.abspath(supposed_path))
179-
return path.split('/')[-1], path
179+
return path.split(os.sep)[-1], path
180180

181181
raise AppMakerException(
182182
f"Unable to find application template {name_or_path}. "
@@ -221,7 +221,7 @@ def parent_paths(self):
221221

222222
if os.path.exists(path_full):
223223
# Check parent file exists in template.
224-
paths.append(os.path.join(parent.name, path_rel))
224+
paths.append(f'{parent.name}/{path_rel}')
225225

226226
if parent.is_default:
227227
break

src/makeapp/helpers/vcs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ def commit(self, message: str):
110110
:param message: Commit description.
111111
112112
"""
113-
self.run_command("commit -m '%s'" % message.replace("'", "''"))
113+
with NamedTemporaryFile() as f:
114+
f.write(message.encode())
115+
f.flush()
116+
117+
self.run_command(f'commit -F "{f.name}"')
114118

115119
def get_remotes(self):
116120
"""Returns a list of remotes."""

src/makeapp/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,10 @@ def check_command(command: str, *, hint: str):
8787
:param hint:
8888
8989
"""
90-
try:
91-
run_command(f'type {command}')
92-
93-
except CommandError as e:
90+
if shutil.which(command) is None:
9491
raise CommandError(
9592
f"Failed to execute '{command}' command. "
96-
f"Check {hint} is installed and available.") from e
93+
f"Check {hint} is installed and available.")
9794

9895

9996
def run_command(command: str, *, err_msg: str = '', env: dict | None = None, capture: bool = True) -> list[str]:
@@ -187,4 +184,8 @@ def sync(cls) -> list[str]:
187184

188185
@classmethod
189186
def install(cls):
190-
return run_command('curl -LsSf https://astral.sh/uv/install.sh | sh', capture=False)
187+
if sys.platform == 'win32':
188+
cmd = 'powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"'
189+
else:
190+
cmd = 'curl -LsSf https://astral.sh/uv/install.sh | sh'
191+
return run_command(cmd, capture=False)

0 commit comments

Comments
 (0)