Skip to content

Commit 6ac2c69

Browse files
committed
build: modernize packaging
1 parent 80740f2 commit 6ac2c69

File tree

9 files changed

+127
-140
lines changed

9 files changed

+127
-140
lines changed

Makefile

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
BEHAVE = behave
22
MAKE = make
33
PYTHON = python
4-
SETUP = $(PYTHON) ./setup.py
4+
BUILD = $(PYTHON) -m build
5+
TWINE = $(PYTHON) -m twine
56

6-
.PHONY: accept clean coverage docs readme register sdist test upload
7+
.PHONY: accept build clean cleandocs coverage docs install opendocs sdist test
8+
.PHONY: test-upload wheel
79

810
help:
911
@echo "Please use \`make <target>' where <target> is one or more of"
10-
@echo " accept run acceptance tests using behave"
11-
@echo " clean delete intermediate work product and start fresh"
12-
@echo " cleandocs delete intermediate documentation files"
13-
@echo " coverage run nosetests with coverage"
14-
@echo " docs generate documentation"
15-
@echo " opendocs open browser to local version of documentation"
16-
@echo " register update metadata (README.rst) on PyPI"
17-
@echo " sdist generate a source distribution into dist/"
18-
@echo " upload upload distribution tarball to PyPI"
12+
@echo " accept run acceptance tests using behave"
13+
@echo " build generate both sdist and wheel suitable for upload to PyPI"
14+
@echo " clean delete intermediate work product and start fresh"
15+
@echo " cleandocs delete intermediate documentation files"
16+
@echo " coverage run pytest with coverage"
17+
@echo " docs generate documentation"
18+
@echo " opendocs open browser to local version of documentation"
19+
@echo " register update metadata (README.rst) on PyPI"
20+
@echo " sdist generate a source distribution into dist/"
21+
@echo " test run unit tests using pytest"
22+
@echo " test-upload upload distribution to TestPyPI"
23+
@echo " upload upload distribution tarball to PyPI"
24+
@echo " wheel generate a binary distribution into dist/"
1925

2026
accept:
2127
$(BEHAVE) --stop
2228

29+
build:
30+
$(BUILD)
31+
2332
clean:
2433
find . -type f -name \*.pyc -exec rm {} \;
2534
rm -rf dist *.egg-info .coverage .DS_Store
@@ -33,14 +42,23 @@ coverage:
3342
docs:
3443
$(MAKE) -C docs html
3544

45+
install:
46+
pip install -Ue .
47+
3648
opendocs:
3749
open docs/.build/html/index.html
3850

39-
register:
40-
$(SETUP) register
41-
4251
sdist:
43-
$(SETUP) sdist
52+
$(BUILD) --sdist .
53+
54+
test:
55+
pytest -x
56+
57+
test-upload: sdist wheel
58+
$(TWINE) upload --repository testpypi dist/*
59+
60+
upload: sdist wheel
61+
$(TWINE) upload dist/*
4462

45-
upload:
46-
$(SETUP) sdist upload
63+
wheel:
64+
$(BUILD) --wheel .

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. image:: https://travis-ci.org/python-openxml/python-docx.svg?branch=master
22
:target: https://travis-ci.org/python-openxml/python-docx
33

4-
*python-docx* is a Python library for creating and updating Microsoft Word
4+
*python-docx* is a Python library for reading, creating, and updating Microsoft Word
55
(.docx) files.
66

77
More information is available in the `python-docx documentation`_.

pyproject.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0.0"]
3+
4+
[project]
5+
name = "python-docx"
6+
authors = [{name = "Steve Canny", email = "stcanny@gmail.com"}]
7+
classifiers = [
8+
"Development Status :: 5 - Production/Stable",
9+
"Environment :: Console",
10+
"Intended Audience :: Developers",
11+
"License :: OSI Approved :: MIT License",
12+
"Operating System :: OS Independent",
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.7",
16+
"Programming Language :: Python :: 3.8",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Topic :: Office/Business :: Office Suites",
21+
"Topic :: Software Development :: Libraries",
22+
]
23+
dependencies = [
24+
"lxml>=2.3.2",
25+
]
26+
description = "Create, read, and update Microsoft Word .docx files."
27+
dynamic = ["version"]
28+
keywords = ["docx", "office", "openxml", "word"]
29+
license = { text = "MIT" }
30+
readme = "README.rst"
31+
requires-python = ">=3.7"
32+
33+
[project.urls]
34+
Changelog = "https://github.com/python-openxml/python-docx/blob/master/HISTORY.rst"
35+
Documentation = "https://python-docx.readthedocs.org/en/latest/"
36+
Homepage = "https://github.com/python-openxml/python-docx"
37+
Repository = "https://github.com/python-openxml/python-docx"
38+
39+
[tool.black]
40+
target-version = ["py37", "py38", "py39", "py310", "py311"]
41+
42+
[tool.pytest.ini_options]
43+
norecursedirs = [
44+
"doc",
45+
"docx",
46+
"*.egg-info",
47+
"features",
48+
".git",
49+
"ref",
50+
"_scratch",
51+
".tox",
52+
]
53+
python_files = ["test_*.py"]
54+
python_classes = ["Test", "Describe"]
55+
python_functions = ["it_", "they_", "and_it_", "but_it_"]
56+
57+
[tool.ruff]
58+
exclude = []
59+
ignore = [
60+
"COM812", # -- over-aggressively insists on trailing commas where not desired --
61+
]
62+
select = [
63+
# "C4", # -- flake8-comprehensions --
64+
"COM", # -- flake8-commas --
65+
"E", # -- pycodestyle errors --
66+
"F", # -- pyflakes --
67+
# "I", # -- isort (imports) --
68+
"PLR0402", # -- Name compared with itself like `foo == foo` --
69+
# "PT", # -- flake8-pytest-style --
70+
# "SIM", # -- flake8-simplify --
71+
"UP015", # -- redundant `open()` mode parameter (like "r" is default) --
72+
"UP018", # -- Unnecessary {literal_type} call like `str("abc")`. (rewrite as a literal) --
73+
"UP032", # -- Use f-string instead of `.format()` call --
74+
"UP034", # -- Avoid extraneous parentheses --
75+
]
76+
target-version = "py37"
77+
78+
[tool.setuptools.dynamic]
79+
version = {attr = "docx.__version__"}

requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r requirements-test.txt
2+
build
3+
setuptools>=61.0.0
4+
tox
5+
twine

requirements-test.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-r requirements.txt
2+
behave>=1.2.3
3+
pyparsing>=2.0.1
4+
pytest>=2.5
5+
ruff

requirements.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
behave>=1.2.3
2-
flake8>=2.0
31
lxml>=3.1.0
4-
mock>=1.0.1
5-
pyparsing>=2.0.1
6-
pytest>=2.5

setup.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

src/docx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from docx.api import Document # noqa
44

5-
__version__ = "0.8.11"
5+
__version__ = "1.0.0rc1"
66

77

88
# register custom Part classes with opc package reader

tox.ini

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
#
2-
# Configuration for tox and pytest
3-
4-
[flake8]
5-
exclude = dist,docs,*.egg-info,.git,ref,_scratch,.tox
6-
max-line-length = 88
7-
8-
[pytest]
9-
norecursedirs = doc docx *.egg-info features .git ref _scratch .tox
10-
python_files = test_*.py
11-
python_classes = Test Describe
12-
python_functions = it_ they_ and_it_ but_it_
13-
141
[tox]
15-
envlist = py26, py27, py34, py35, py36, py38
2+
envlist = py37, py38, py39, py310, py311
163

174
[testenv]
185
deps =
@@ -24,20 +11,3 @@ deps =
2411
commands =
2512
py.test -qx
2613
behave --format progress --stop --tags=-wip
27-
28-
[testenv:py26]
29-
deps =
30-
importlib>=1.0.3
31-
behave
32-
lxml
33-
mock
34-
pyparsing
35-
pytest
36-
37-
[testenv:py27]
38-
deps =
39-
behave
40-
lxml
41-
mock
42-
pyparsing
43-
pytest

0 commit comments

Comments
 (0)