Skip to content

Commit 40301cc

Browse files
committed
build: modernize build process
- Move to `pyproject.toml` - Update support to 3.8+
1 parent af6a8f7 commit 40301cc

File tree

14 files changed

+89
-152
lines changed

14 files changed

+89
-152
lines changed

Makefile

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,55 @@
11
BEHAVE = behave
22
MAKE = make
3-
PYTHON = python
4-
SETUP = $(PYTHON) ./setup.py
5-
TWINE = $(PYTHON) -m twine
6-
7-
.PHONY: accept build clean cleandocs coverage docs opendocs
83

4+
.PHONY: help
95
help:
106
@echo "Please use \`make <target>' where <target> is one or more of"
11-
@echo " accept run acceptance tests using behave"
12-
@echo " clean delete intermediate work product and start fresh"
13-
@echo " cleandocs delete cached HTML documentation and start fresh"
14-
@echo " coverage run nosetests with coverage"
15-
@echo " docs build HTML documentation using Sphinx (incremental)"
16-
@echo " opendocs open local HTML documentation in browser"
17-
@echo " readme update README.html from README.rst"
18-
@echo " sdist generate a source distribution into dist/"
19-
@echo " upload upload distribution tarball to PyPI"
20-
7+
@echo " accept run acceptance tests using behave"
8+
@echo " build generate both sdist and wheel suitable for upload to PyPI"
9+
@echo " clean delete intermediate work product and start fresh"
10+
@echo " cleandocs delete cached HTML documentation and start fresh"
11+
@echo " coverage run nosetests with coverage"
12+
@echo " docs build HTML documentation using Sphinx (incremental)"
13+
@echo " opendocs open local HTML documentation in browser"
14+
@echo " test-upload upload distribution to TestPyPI"
15+
@echo " upload upload distribution tarball to PyPI"
16+
17+
.PHONY: accept
2118
accept:
2219
$(BEHAVE) --stop
2320

21+
.PHONY: build
2422
build:
2523
rm -rf dist
26-
$(SETUP) bdist_wheel sdist
24+
python -m build
25+
twine check dist/*
2726

27+
.PHONY: clean
2828
clean:
2929
find . -type f -name \*.pyc -exec rm {} \;
3030
find . -type f -name .DS_Store -exec rm {} \;
3131
rm -rf dist .coverage
3232

33+
.PHONY: cleandocs
3334
cleandocs:
3435
$(MAKE) -C docs clean
3536

37+
.PHONY: coverage
3638
coverage:
3739
py.test --cov-report term-missing --cov=pptx --cov=tests
3840

41+
.PHONY: docs
3942
docs:
4043
$(MAKE) -C docs html
4144

45+
.PHONY: opendocs
4246
opendocs:
4347
open docs/.build/html/index.html
4448

49+
.PHONY: test-upload
4550
test-upload: build
46-
$(TWINE) upload --repository testpypi dist/*
51+
twine upload --repository testpypi dist/*
4752

53+
.PHONY: upload
4854
upload: clean build
49-
$(TWINE) upload dist/*
55+
twine upload dist/*

pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "python-pptx"
7+
authors = [{name = "Steve Canny", email = "stcanny@gmail.com"}]
8+
classifiers = [
9+
"Development Status :: 5 - Production/Stable",
10+
"Environment :: Console",
11+
"Intended Audience :: Developers",
12+
"License :: OSI Approved :: MIT License",
13+
"Operating System :: OS Independent",
14+
"Programming Language :: Python",
15+
"Programming Language :: Python :: 3",
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+
"Programming Language :: Python :: 3.12",
21+
"Topic :: Office/Business :: Office Suites",
22+
"Topic :: Software Development :: Libraries",
23+
]
24+
dependencies = [
25+
"Pillow>=3.3.2",
26+
"XlsxWriter>=0.5.7",
27+
"lxml>=3.1.0",
28+
"typing_extensions>=4.9.0",
29+
]
30+
description = "Create, read, and update PowerPoint 2007+ (.pptx) files."
31+
dynamic = ["version"]
32+
keywords = ["powerpoint", "ppt", "pptx", "openxml", "office"]
33+
license = { text = "MIT" }
34+
readme = "README.rst"
35+
requires-python = ">=3.8"
36+
37+
[project.urls]
38+
Changelog = "https://github.com/scanny/python-pptx/blob/master/HISTORY.rst"
39+
Documentation = "https://python-pptx.readthedocs.io/en/latest/"
40+
Homepage = "https://github.com/scanny/python-pptx"
41+
Repository = "https://github.com/scanny/python-pptx"
42+
143
[tool.black]
244
line-length = 100
345

@@ -98,3 +140,6 @@ ignore = [
98140

99141
[tool.ruff.lint.isort]
100142
known-first-party = ["pptx"]
143+
144+
[tool.setuptools.dynamic]
145+
version = {attr = "pptx.__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+
ruff
4+
setuptools>=61.0.0
5+
twine

requirements-docs.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Sphinx==1.8.6
2+
Jinja2==2.11.3
3+
MarkupSafe==0.23
4+
alabaster<0.7.14
5+
-e .

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pytest>=2.5
55
pytest-coverage
66
pytest-xdist
77
ruff
8+
tox

setup.cfg

Whitespace-only changes.

setup.py

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

src/pptx/opc/package.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from __future__ import annotations
88

99
import collections
10-
from collections.abc import Mapping
11-
from typing import IO, TYPE_CHECKING, DefaultDict, Iterator, Set, cast
10+
from typing import IO, TYPE_CHECKING, DefaultDict, Iterator, Mapping, Set, cast
1211

1312
from pptx.opc.constants import RELATIONSHIP_TARGET_MODE as RTM
1413
from pptx.opc.constants import RELATIONSHIP_TYPE as RT
@@ -428,7 +427,7 @@ def part(self):
428427

429428
def _rel_ref_count(self, rId: str) -> int:
430429
"""Return int count of references in this part's XML to `rId`."""
431-
return len([r for r in cast(list[str], self._element.xpath("//@r:id")) if r == rId])
430+
return len([r for r in cast("list[str]", self._element.xpath("//@r:id")) if r == rId])
432431

433432

434433
class PartFactory:

src/pptx/opc/serialized.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import os
66
import posixpath
77
import zipfile
8-
from collections.abc import Container
9-
from typing import IO, TYPE_CHECKING, Any, Sequence
8+
from typing import IO, TYPE_CHECKING, Any, Container, Sequence
109

1110
from pptx.exc import PackageNotFoundError
1211
from pptx.opc.constants import CONTENT_TYPE as CT

src/pptx/oxml/presentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def _next_id(self) -> int:
7676
MIN_SLIDE_ID = 256
7777
MAX_SLIDE_ID = 2147483647
7878

79-
used_ids = [int(s) for s in cast(list[str], self.xpath("./p:sldId/@id"))]
79+
used_ids = [int(s) for s in cast("list[str]", self.xpath("./p:sldId/@id"))]
8080
simple_next = max([MIN_SLIDE_ID - 1] + used_ids) + 1
8181
if simple_next <= MAX_SLIDE_ID:
8282
return simple_next

0 commit comments

Comments
 (0)