Skip to content

Commit 7bad1b8

Browse files
authored
rfctr: modernize for Python 3 (#11)
- Use uv for package management, get rid of setup.py etc. - Move source to `src/` - Add type-annotations - Blacken code (100-character line-length) - Reformat docstrings to PEP257. - Add GitHub Actions CI. - Get docs working. - Update tox config.
1 parent 0fc9766 commit 7bad1b8

Some content is hidden

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

44 files changed

+3482
-2576
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
push:
8+
branches:
9+
- master
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
python-version: ["3.9", "3.10", "3.11", "3.12"]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v2
28+
with:
29+
version: "0.4.15"
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
run: uv python install ${{ matrix.python-version }}
33+
34+
- name: Install the project
35+
run: uv sync --all-extras --dev
36+
37+
- name: Test with pytest + behave
38+
run: |
39+
uv run pytest --cov-report term-missing --cov=opcdiag --cov=tests tests
40+
uv run behave

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/.coverage
22
/dist/
33
/docs/.build/
4-
/*.egg-info
4+
/src/*.egg-info
55
*.pyc
66
_scratch/
77
Session.vim

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
History
22
=======
33

4+
1.1.0 (2024-09-22)
5+
------------------
6+
7+
* Modernize and repackage with support for Python 3.
8+
9+
410
1.0.0 (2014-01-14)
511
------------------
612

Makefile

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,53 @@
1-
BEHAVE = behave
21
PACKAGE = opcdiag
3-
PYTHON = python
4-
SETUP = $(PYTHON) ./setup.py
52

63
.PHONY: accept clean coverage readme register test sdist upload
74

85
help:
96
@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 " coverage run nosetests with coverage"
13-
@echo " readme update README.html from README.rst"
14-
@echo " register update metadata (README.rst) on PyPI"
15-
@echo " test run tests using setup.py"
16-
@echo " sdist generate a source distribution into dist/"
17-
@echo " upload upload distribution tarball to PyPI"
18-
7+
@echo " accept run acceptance tests using behave"
8+
@echo " build generate a source distribution and wheel into dist/"
9+
@echo " clean delete intermediate work product and start fresh"
10+
@echo " cleandocs delete generated HTML documentation"
11+
@echo " coverage run unit tests with coverage"
12+
@echo " docs generate HTML documentation with Sphinx"
13+
@echo " test run unit tests"
14+
@echo " test-upload upload distribution artifacts in dist/ to Test-PyPI"
15+
@echo " upload upload distribution artifacts in dist/ to PyPI"
16+
17+
.PHONY: accept
1918
accept:
20-
$(BEHAVE) --stop
19+
uv run behave --stop
20+
21+
.PHONY: build
22+
build:
23+
rm -rf dist
24+
uv build
2125

26+
.PHONY: clean
2227
clean:
2328
find . -type f -name \*.pyc -exec rm {} \;
2429
rm -rf dist *.egg-info .coverage .DS_Store
2530

26-
coverage:
27-
py.test --cov-report term-missing --cov=$(PACKAGE) tests/
28-
29-
readme:
30-
rst2html README.rst >README.html
31-
open README.html
31+
.PHONY: cleandocs
32+
cleandocs:
33+
$(MAKE) -C docs clean
3234

33-
register:
34-
$(SETUP) register
35+
.PHONY: coverage
36+
coverage:
37+
uv run pytest --cov-report term-missing --cov=$(PACKAGE) --cov=tests tests/
3538

36-
sdist:
37-
$(SETUP) sdist
39+
.PHONY: docs
40+
docs:
41+
$(MAKE) -C docs html
3842

43+
.PHONY: test
3944
test:
40-
$(SETUP) test
45+
uv run pytest tests
46+
47+
.PHONY: test-upload
48+
test-upload: build
49+
uv run twine upload --repository testpypi dist/*
4150

51+
.PHONY: upload
4252
upload:
43-
$(SETUP) sdist upload
53+
uv run twine upload dist/*

README.rst renamed to README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ and PowerPoint files from Office 2007 and later. Also known as *Office Open
33
XML*, the structure of these files adheres to the Open Packaging Convention
44
(OPC), specified by ISO/IEC 29500.
55

6-
*opc-diag* provides the ``opc`` command, which allows OPC files to be browsed,
6+
*opc-diag* provides the `opc` command, which allows OPC files to be browsed,
77
diff-ed, extracted, repackaged, and parts from one to be substituted into
88
another.
99

@@ -13,16 +13,16 @@ manipulates Microsoft Office documents.
1313
A typical use would be diff-ing a Word file from before and after an operation,
1414
say inserting a paragraph, to identify the specific changes Word made to the
1515
XML. This is handy when one is developing software to do the same without
16-
Word's help::
16+
Word's help:
1717

18-
$ opc diff before.docx after.docx
18+
```bash
19+
$ opc diff before.docx after.docx
20+
```
1921

2022
Another main use is to diagnose an issue causing an Office document to not load
2123
cleanly, typically because the software that generated it has a bug. These
2224
problems can be tedious and often difficult to diagnose without tools like
2325
*opc-diag*, and were the primary motivation for developing it.
2426

25-
More information is available in the `opc-diag documentation`_.
26-
27-
.. _`opc-diag documentation`:
28-
https://opc-diag.readthedocs.org/en/latest/
27+
More information is available in the
28+
[opc-diag documentation](https://opc-diag.readthedocs.org/en/latest/)

0 commit comments

Comments
 (0)