Skip to content

Commit

Permalink
rfctr: modernize for Python 3 (#11)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
scanny authored Sep 23, 2024
1 parent 0fc9766 commit 7bad1b8
Show file tree
Hide file tree
Showing 44 changed files with 3,482 additions and 2,576 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ci

on:
pull_request:
branches:
- master
push:
branches:
- master

permissions:
contents: write

jobs:

build:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.15"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install the project
run: uv sync --all-extras --dev

- name: Test with pytest + behave
run: |
uv run pytest --cov-report term-missing --cov=opcdiag --cov=tests tests
uv run behave
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/.coverage
/dist/
/docs/.build/
/*.egg-info
/src/*.egg-info
*.pyc
_scratch/
Session.vim
Expand Down
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
History
=======

1.1.0 (2024-09-22)
------------------

* Modernize and repackage with support for Python 3.


1.0.0 (2014-01-14)
------------------

Expand Down
60 changes: 35 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,43 +1,53 @@
BEHAVE = behave
PACKAGE = opcdiag
PYTHON = python
SETUP = $(PYTHON) ./setup.py

.PHONY: accept clean coverage readme register test sdist upload

help:
@echo "Please use \`make <target>' where <target> is one or more of"
@echo " accept run acceptance tests using behave"
@echo " clean delete intermediate work product and start fresh"
@echo " coverage run nosetests with coverage"
@echo " readme update README.html from README.rst"
@echo " register update metadata (README.rst) on PyPI"
@echo " test run tests using setup.py"
@echo " sdist generate a source distribution into dist/"
@echo " upload upload distribution tarball to PyPI"

@echo " accept run acceptance tests using behave"
@echo " build generate a source distribution and wheel into dist/"
@echo " clean delete intermediate work product and start fresh"
@echo " cleandocs delete generated HTML documentation"
@echo " coverage run unit tests with coverage"
@echo " docs generate HTML documentation with Sphinx"
@echo " test run unit tests"
@echo " test-upload upload distribution artifacts in dist/ to Test-PyPI"
@echo " upload upload distribution artifacts in dist/ to PyPI"

.PHONY: accept
accept:
$(BEHAVE) --stop
uv run behave --stop

.PHONY: build
build:
rm -rf dist
uv build

.PHONY: clean
clean:
find . -type f -name \*.pyc -exec rm {} \;
rm -rf dist *.egg-info .coverage .DS_Store

coverage:
py.test --cov-report term-missing --cov=$(PACKAGE) tests/

readme:
rst2html README.rst >README.html
open README.html
.PHONY: cleandocs
cleandocs:
$(MAKE) -C docs clean

register:
$(SETUP) register
.PHONY: coverage
coverage:
uv run pytest --cov-report term-missing --cov=$(PACKAGE) --cov=tests tests/

sdist:
$(SETUP) sdist
.PHONY: docs
docs:
$(MAKE) -C docs html

.PHONY: test
test:
$(SETUP) test
uv run pytest tests

.PHONY: test-upload
test-upload: build
uv run twine upload --repository testpypi dist/*

.PHONY: upload
upload:
$(SETUP) sdist upload
uv run twine upload dist/*
14 changes: 7 additions & 7 deletions README.rst → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ and PowerPoint files from Office 2007 and later. Also known as *Office Open
XML*, the structure of these files adheres to the Open Packaging Convention
(OPC), specified by ISO/IEC 29500.

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

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

$ opc diff before.docx after.docx
```bash
$ opc diff before.docx after.docx
```

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

More information is available in the `opc-diag documentation`_.

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

0 comments on commit 7bad1b8

Please sign in to comment.