From 0fc5cd5931a56aceacf287aa904f62453cb12337 Mon Sep 17 00:00:00 2001 From: Pieter P Date: Tue, 28 Jun 2022 22:17:20 +0200 Subject: [PATCH] [Win] properly escape backslashes editable paths --- src/py_build_cmake/build.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/py_build_cmake/build.py b/src/py_build_cmake/build.py index 40f3909..da75cc8 100644 --- a/src/py_build_cmake/build.py +++ b/src/py_build_cmake/build.py @@ -356,6 +356,8 @@ def write_license_files(self, license, srcdir: Path, distinfo_dir: Path): def write_editable_wrapper(self, tmp_build_dir: Path, src_dir: Path, pkg): # Write a fake __init__.py file that points to the development folder tmp_pkg: Path = tmp_build_dir / pkg.name + pkgpath = Path(pkg.path) + initpath = pkgpath / '__init__.py' os.makedirs(tmp_pkg, exist_ok=True) special_dunders = [ '__builtins__', '__cached__', '__file__', '__loader__', '__name__', @@ -363,11 +365,11 @@ def write_editable_wrapper(self, tmp_build_dir: Path, src_dir: Path, pkg): ] content = f"""\ # First extend the search path with the development folder - __spec__.submodule_search_locations.insert(0, "{pkg.path}") + __spec__.submodule_search_locations.insert(0, {str(pkgpath)!a}) # Now manually import the development __init__.py from importlib import util as _util _spec = _util.spec_from_file_location("{pkg.name}", - "{pkg.path}/__init__.py") + {str(initpath)!a}) _mod = _util.module_from_spec(_spec) _spec.loader.exec_module(_mod) # After importing, add its symbols to our global scope