Skip to content

Commit 30402cf

Browse files
committed
Fix windows support
1 parent 0657363 commit 30402cf

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/semiwrap/cmd_dat2cpp.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def _write_wrapper_cpp(input_dat: pathlib.Path, output_cpp: pathlib.Path):
1818
assert isinstance(hctx, HeaderContext)
1919

2020
content = render_wrapped_cpp(hctx)
21-
output_cpp.write_text(content)
21+
with open(output_cpp, "w", encoding="utf-8") as fp:
22+
fp.write(content)
2223

2324

2425
def main():

src/semiwrap/cmd_genmeson.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def getvar(self, item: VarTypes) -> str:
6767
if isinstance(item, InputFile):
6868
# .. this probably isn't right either, what should this be relative to?
6969
# .. TODO should use files()? but maybe only if this is actually a variable
70-
return _make_string(str(item.path.absolute()))
70+
return _make_string(item.path.absolute().as_posix())
7171
# var = f"sw_in_{self.idx}"
7272
elif isinstance(item, OutputFile):
7373
return _make_string(item.name)
@@ -101,7 +101,7 @@ def _render_build_target(r: RenderBuffer, vc: VarCache, bt: BuildTarget):
101101
if isinstance(arg, str):
102102
cmd.append(_make_string(arg))
103103
elif isinstance(arg, pathlib.Path):
104-
cmd.append(_make_string(str(arg.absolute())))
104+
cmd.append(_make_string(arg.absolute().as_posix()))
105105
elif isinstance(arg, (BuildTarget, InputFile)):
106106
cmd.append(f"'@INPUT{len(tinput)}@'")
107107
tinput.append(vc.getvar(arg))
@@ -158,7 +158,7 @@ def _render_include_directories(
158158
incs = [pathlib.Path(os.path.relpath(str(p), meson_build_parent)) for p in incs]
159159

160160
_render_meson_args(
161-
r, "include_directories", [_make_string(str(inc)) for inc in incs]
161+
r, "include_directories", [_make_string(inc.as_posix()) for inc in incs]
162162
)
163163

164164

src/semiwrap/cmd_make_pyi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def _write_pyi(package_name, generated_pyi: T.Dict[pathlib.PurePath, pathlib.Pat
5555
# to our desired location
5656
tmpdir_pth = pathlib.Path(tmpdir)
5757
for infile, output in generated_pyi.items():
58+
output.unlink(missing_ok=True)
5859
(tmpdir_pth / infile).rename(output)
5960

6061

src/semiwrap/makeplan.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _process_extension_module(
210210

211211
# Detect the location of the package in the source tree
212212
package_init_py = self.pyproject.package_root / package_path / "__init__.py"
213-
self.pyi_args += (parent_package, str(package_init_py))
213+
self.pyi_args += (parent_package, package_init_py.as_posix())
214214

215215
depends = self.pyproject.get_extension_deps(extension)
216216
depends.append("semiwrap")
@@ -328,11 +328,11 @@ def _process_extension_module(
328328

329329
if subpackages:
330330
pyi_elems = base_pyi_elems + ["__init__.pyi"]
331-
pyi_args = [str(pathlib.PurePath(*pyi_elems)), OutputFile("__init__.pyi")]
331+
pyi_args = [pathlib.PurePath(*pyi_elems).as_posix(), OutputFile("__init__.pyi")]
332332
for subpackage in subpackages:
333333
pyi_elems = base_pyi_elems + [f"{subpackage}.pyi"]
334334
pyi_args += [
335-
str(pathlib.PurePath(*pyi_elems)),
335+
pathlib.PurePath(*pyi_elems).as_posix(),
336336
OutputFile(f"{subpackage}.pyi"),
337337
]
338338

@@ -352,7 +352,7 @@ def _process_extension_module(
352352
command="make-pyi",
353353
args=(
354354
package_name,
355-
str(pathlib.PurePath(*base_pyi_elems)),
355+
pathlib.PurePath(*base_pyi_elems).as_posix(),
356356
OutputFile(f"{module_name}.pyi"),
357357
"--",
358358
),

0 commit comments

Comments
 (0)