Skip to content

Commit

Permalink
[Win] properly escape backslashes editable paths
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Jun 28, 2022
1 parent 1b81559 commit 0fc5cd5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/py_build_cmake/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,20 @@ 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__',
'__package__', '__path__', '__spec__'
]
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
Expand Down

0 comments on commit 0fc5cd5

Please sign in to comment.