Przeglądaj źródła

Minor fix on path to make it work in Windows (#2494)

Tianze 1 rok temu
rodzic
commit
a14575009c
1 zmienionych plików z 7 dodań i 3 usunięć
  1. 7 3
      scripts/pyi_generator.py

+ 7 - 3
scripts/pyi_generator.py

@@ -703,7 +703,8 @@ class PyiGenerator:
     current_module: Any = {}
     current_module: Any = {}
 
 
     def _write_pyi_file(self, module_path: Path, source: str):
     def _write_pyi_file(self, module_path: Path, source: str):
-        relpath = _relative_to_pwd(module_path)
+        relpath = str(_relative_to_pwd(module_path)).replace("\\", "/")
+        print(f"Writing {relpath}")
         pyi_content = [
         pyi_content = [
             f'"""Stub file for {relpath}"""',
             f'"""Stub file for {relpath}"""',
             "# ------------------- DO NOT EDIT ----------------------",
             "# ------------------- DO NOT EDIT ----------------------",
@@ -731,9 +732,12 @@ class PyiGenerator:
         logger.info(f"Wrote {relpath}")
         logger.info(f"Wrote {relpath}")
 
 
     def _scan_file(self, module_path: Path):
     def _scan_file(self, module_path: Path):
-        #  module_import = str(module_path.with_suffix("")).replace("/", ".")
         module_import = (
         module_import = (
-            _relative_to_pwd(module_path).with_suffix("").as_posix().replace("/", ".")
+            _relative_to_pwd(module_path)
+            .with_suffix("")
+            .as_posix()
+            .replace("/", ".")
+            .replace("\\", ".")
         )
         )
         module = importlib.import_module(module_import)
         module = importlib.import_module(module_import)
         logger.debug(f"Read {module_path}")
         logger.debug(f"Read {module_path}")