Skip to content

Commit 80740f2

Browse files
committed
build: move docx package under src/ directory
This improves packaging reliability because it prevents tests from running against the current directory instead of the installed version of the package.
1 parent 629f942 commit 80740f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+8
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
/build/
12
.coverage
23
/dist/
34
/docs/.build/
4-
/*.egg-info
5+
/src/*.egg-info
56
*.pyc
67
.pytest_cache/
78
_scratch/

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
include HISTORY.rst LICENSE README.rst tox.ini
2-
graft docx/templates
2+
graft src/docx/templates
33
graft features
44
graft tests
55
graft docs

setup.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def text_of(relpath):
2121
# Read the version from docx.__version__ without importing the package
2222
# (and thus attempting to import packages it depends on that may not be
2323
# installed yet)
24-
version = re.search(r'__version__ = "([^"]+)"', text_of("docx/__init__.py")).group(1)
24+
version = re.search(r'__version__ = "([^"]+)"', text_of("src/docx/__init__.py")).group(
25+
1
26+
)
2527

2628

2729
NAME = "python-docx"
@@ -32,7 +34,7 @@ def text_of(relpath):
3234
AUTHOR_EMAIL = "python-docx@googlegroups.com"
3335
URL = "https://github.com/python-openxml/python-docx"
3436
LICENSE = text_of("LICENSE")
35-
PACKAGES = find_packages(exclude=["tests", "tests.*"])
37+
PACKAGES = find_packages(where="src")
3638
PACKAGE_DATA = {"docx": ["templates/*.xml", "templates/*.docx"]}
3739

3840
INSTALL_REQUIRES = ["lxml>=2.3.2"]
@@ -72,6 +74,7 @@ def text_of(relpath):
7274
"license": LICENSE,
7375
"packages": PACKAGES,
7476
"package_data": PACKAGE_DATA,
77+
"package_dir": {"": "src"},
7578
"install_requires": INSTALL_REQUIRES,
7679
"tests_require": TESTS_REQUIRE,
7780
"test_suite": TEST_SUITE,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)