1919import os
2020import subprocess
2121
22+ # Absolute path to the directory containing this file, so include_dirs and
23+ # sources resolve correctly regardless of the working directory pip uses.
24+ ROOT = os .path .dirname (os .path .abspath (__file__ ))
25+
2226
2327def _is_mingw () -> bool :
2428 """Return True when building with MinGW-w64 GCC under Windows."""
@@ -82,17 +86,21 @@ def _is_mingw() -> bool:
8286
8387# ─── Source files ─────────────────────────────────────────────────────────────
8488sources = [
85- "python/ python_bindings.cpp" ,
86- "src/ docx_parser.cpp" ,
87- "src/ batch_parser.cpp" ,
88- "src/ zip_reader.cpp" ,
89- "src/ xml_parser.cpp" ,
89+ os . path . join ( ROOT , "python" , " python_bindings.cpp") ,
90+ os . path . join ( ROOT , "src" , " docx_parser.cpp") ,
91+ os . path . join ( ROOT , "src" , " batch_parser.cpp") ,
92+ os . path . join ( ROOT , "src" , " zip_reader.cpp") ,
93+ os . path . join ( ROOT , "src" , " xml_parser.cpp") ,
9094]
9195
9296ext = Extension (
9397 "docx_comment_parser" ,
9498 sources = sources ,
95- include_dirs = ["include" , "vendor" , pybind11_include ],
99+ include_dirs = [
100+ os .path .join (ROOT , "include" ),
101+ os .path .join (ROOT , "vendor" ),
102+ pybind11_include ,
103+ ],
96104 extra_compile_args = extra_compile_args ,
97105 extra_link_args = extra_link_args ,
98106 language = "c++" ,
@@ -103,7 +111,7 @@ def _is_mingw() -> bool:
103111 version = "1.0.0" ,
104112 author = "nick-developer" ,
105113 description = "Fast C++ library for extracting comment metadata from .docx files" ,
106- long_description = open ("README.md" , encoding = "utf-8" ).read () if os .path .exists ("README.md" ) else "" ,
114+ long_description = open (os . path . join ( ROOT , "README.md" ) , encoding = "utf-8" ).read () if os .path .exists (os . path . join ( ROOT , "README.md" ) ) else "" ,
107115 ext_modules = [ext ],
108116 python_requires = ">=3.8" ,
109117 classifiers = [
0 commit comments