Skip to content

Commit 5752afd

Browse files
nicknick
authored andcommitted
update setup to identify root dir and included MANIFEST file for building the whl
1 parent a291108 commit 5752afd

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
BUILDING.md
88
/.vscode
99
/build
10+
/dist

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
recursive-include include *.h
2+
recursive-include vendor *.h *.c
3+
recursive-include src *.cpp *.h
4+
recursive-include python *.cpp

setup.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import os
2020
import 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

2327
def _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 ─────────────────────────────────────────────────────────────
8488
sources = [
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

9296
ext = 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

Comments
 (0)