Skip to content

Commit e8f71d2

Browse files
rlskoeserjdamerow
andauthored
Set up for publishing on PyPI (#60)
* Move tox config into setup.cfg #58 (#59) * Move tox config into setup.cfg #58 Adds a comment documenting everywhere to update python versions when supported versions change * Use tox interpolation syntax and declare dependencies once * Add documentation build to check workflow * Include docs deps in dev deps * Configure tox and github actions to use the same base python version * Python 3.10, not 3.1 GitHub Actions 🙄 * Added label field to UndateInterval, added repr methods, and tests. (#52) * Added label field to UndateInterval, added repr methods, and tests. * Added variable documentation for labels. * dynamically import dateformatter subclasses (#50) * Use pkgutils to dynamically import dateformat formatter subclasses * Adjust formatter import and test to confirm we only import once * Add pytest-ordering dependency to tox * Use python3.8 compatible caching * Add pytest-ordering to tox coverage deps * Create python-publish.yml * Add docs build directory to gitignore * Prep for initial publication on PyPI * Update formatting * Adjust requirement reference syntax * Revise project metadata and tox install commands * Update for formatting & display on PyPI * Add a change log * Add readthedocs badge and link, add placeholder text in docs intro --------- Co-authored-by: Julia Damerow <[email protected]>
1 parent 2129cea commit e8f71d2

File tree

17 files changed

+253
-91
lines changed

17 files changed

+253
-91
lines changed

.github/workflows/check.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: style check
1+
name: style + docs check
22

33
on:
44
pull_request:
@@ -13,14 +13,16 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up Python 3.9
16+
- name: Set up Python 3.10
1717
uses: actions/setup-python@v4
1818
with:
19-
python-version: 3.9
19+
python-version: "3.10"
2020
cache: 'pip'
2121
cache-dependency-path: '**/setup.cfg'
2222
- name: Install package with dependencies
2323
run: pip install -e ".[dev]"
2424
if: steps.python-cache.outputs.cache-hit != 'true'
2525
- name: Run black
2626
run: black src --check --diff
27+
- name: Check that documentation can be built
28+
run: tox -e docs

.github/workflows/python-publish.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
deploy:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
- name: Set up Python
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: '3.x'
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install build
33+
- name: Build package
34+
run: python -m build
35+
- name: Publish package
36+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37+
with:
38+
user: __token__
39+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/unit_tests.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ on:
1010
pull_request:
1111

1212
env:
13-
COV_PYTHON_VERSION: "3.9"
13+
# python version used to calculate and submit code coverage
14+
COV_PYTHON_VERSION: "3.10"
1415

1516
jobs:
1617
python-unit:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wheels/
2424
.installed.cfg
2525
*.egg
2626
MANIFEST
27+
docs/_build/
2728

2829
# Environments
2930
.tox

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Change Log
2+
3+
## 0.1
4+
5+
Pre-alpha version with preliminary `Undate` and `UndateInterval` classes
6+
with support for ISO8601 date format

README.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
# undate-python
22

3-
`undate` is a python library for working with uncertain or partially known dates.
3+
**undate** is a python library for working with uncertain or partially known dates.
4+
5+
It was initially created as part of a [DH-Tech](https://dh-tech.github.io/) hackathon in November 2022.
6+
7+
---
8+
9+
⚠️ **WARNING:** this is pre-alpha software and is **NOT** feature complete! Use with caution. ⚠️
10+
11+
---
412

5-
It was initially created as part of a DH-Tech hackathon in November 2022.
613

714
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
15+
[![Documentation Status](https://readthedocs.org/projects/undate-python/badge/?version=latest)](https://undate-python.readthedocs.io/en/latest/?badge=latest)
816
[![unit tests](https://github.com/dh-tech/undate-python/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/dh-tech/undate-python/actions/workflows/unit_tests.yml)
917
[![codecov](https://codecov.io/gh/dh-tech/undate-python/branch/main/graph/badge.svg?token=GE7HZE8C9D)](https://codecov.io/gh/dh-tech/undate-python)
1018
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1119
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
1220
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
1321
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1422

23+
## Documentation
24+
25+
Project documentation is available on ReadTheDocs https://undate-python.readthedocs.io/en/latest/
26+
1527
## License
1628

1729
This software is licensed under the [Apache 2.0 License](LICENSE.md).
1830

1931
## Installation
2032

33+
To install the most recent release from PyPI:
34+
```sh
35+
pip install undate
36+
```
37+
2138
To install the latest development version from GitHub:
2239
```sh
23-
pip install git+https://github.com/dh-tech/undate-python.git@main#egg=undate
40+
pip install git+https://github.com/dh-tech/undate-python.git@develop#egg=undate
2441
```
2542

2643
To install a specific release or branch, run the following (replace `[tag-name]` with the tag or branch you want to install):

docs/conf.py

+11-15
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,30 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'Undate'
21-
copyright = '2022, DHtech'
22-
author = 'DHtech Community'
20+
project = "Undate"
21+
copyright = "2022, DHtech"
22+
author = "DHtech Community"
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '0.0.1.dev'
25+
release = "0.0.1.dev"
2626

27-
master_doc = 'index'
27+
master_doc = "index"
2828

2929

3030
# -- General configuration ---------------------------------------------------
3131

3232
# Add any Sphinx extension module names here, as strings. They can be
3333
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3434
# ones.
35-
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.intersphinx',
38-
'm2r2'
39-
]
35+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.intersphinx", "m2r2"]
4036

4137
# Add any paths that contain templates here, relative to this directory.
42-
templates_path = ['_templates']
38+
templates_path = ["_templates"]
4339

4440
# List of patterns, relative to source directory, that match files and
4541
# directories to ignore when looking for source files.
4642
# This pattern also affects html_static_path and html_extra_path.
47-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
43+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4844

4945
source_suffix = [".rst", ".md"]
5046

@@ -53,11 +49,11 @@
5349
# The theme to use for HTML and HTML Help pages. See the documentation for
5450
# a list of builtin themes.
5551
#
56-
html_theme = 'sphinx_rtd_theme'
52+
html_theme = "sphinx_rtd_theme"
5753

5854
# Add any paths that contain custom static files (such as style sheets) here,
5955
# relative to this directory. They are copied after the builtin static files,
6056
# so a file named "default.css" will overwrite the builtin "default.css".
61-
html_static_path = ['_static']
57+
html_static_path = ["_static"]
6258

63-
html_logo = '_static/logo.png'
59+
html_logo = "_static/logo.png"

docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Undate documentation
22
====================
33

4-
This project ...
4+
**undate** is a python library for working with uncertain or partially known dates.
55

66

77
.. toctree::

pytest.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
markers =
3-
last: run marked tests after all others
3+
last: run marked tests after all others
4+
first: run marked tests before all others

setup.cfg

+69-9
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
[metadata]
22
name = undate
33
version = attr: undate.__version__
4-
author = 'DHTech'
5-
author_email = '[email protected]'
6-
description = "library for working with uncertain, fuzzy, or "
7-
+ "partially unknown dates and date intervals"
4+
author = DHTech
5+
author_email = "[email protected]"
6+
description = "library for working with uncertain, fuzzy, or partially unknown dates and date intervals"
87
long_description = file: README.md
9-
license="Apache License, Version 2.0",
8+
license="Apache License, Version 2.0"
109
long_description_content_type = text/markdown
11-
url = https://github.com/dh-tech/hackathon-2022
10+
url = https://github.com/dh-tech/undate-python
1211
project_urls =
13-
Project Home = https://dh-tech.github.io
12+
Project Home = https://github.com/dh-tech/undate-python
1413
Bug Tracker = https://github.com/dh-tech/undate-python/issues
14+
keywords = "dates dating uncertainty uncertain-dates unknown partially-known digital-humanities"
1515
classifiers =
1616
Development Status :: 2 - Pre-Alpha
1717
Programming Language :: Python :: 3
18+
Programming Language :: Python :: 3.8
19+
Programming Language :: Python :: 3.9
20+
Programming Language :: Python :: 3.10
21+
Programming Language :: Python :: 3.11
1822
Intended Audience :: Developers
1923
License :: OSI Approved :: Apache Software License
2024
Operating System :: OS Independent
2125
Topic :: Software Development :: Libraries :: Python Modules
2226
Topic :: Utilities
2327
Typing :: Typed
2428

29+
# When supported python versions change, update all the following places:
30+
# - classifiers
31+
# - minimum version required in python_requires
32+
# - tox envlist
33+
# - gh-actions
34+
# - python versions in matrix config in unit_tests.yml
35+
2536
[options]
2637
package_dir =
2738
= src
2839
packages = find:
2940
python_requires = >=3.8
3041
install_requires =
3142
python-dateutil
43+
3244
[options.extras_require]
3345
all =
3446
%(dev)s
@@ -37,13 +49,61 @@ dev =
3749
black>=22.10.0
3850
pre-commit>=2.20.0
3951
tox
40-
sphinx
4152
twine
4253
wheel
43-
pytest-cov
54+
build
55+
%(docs)s
4456
test =
4557
pytest>=7.2
4658
pytest-ordering
59+
pytest-cov
60+
docs =
61+
sphinx
62+
sphinx_rtd_theme
63+
m2r2
4764

4865
[options.packages.find]
4966
where = src
67+
68+
[tox:tox]
69+
envlist = py38, py39, py310, py311
70+
isolated_build = True
71+
72+
[gh-actions]
73+
python =
74+
3.8: py38
75+
3.9: py39
76+
3.10: py310
77+
3.11: py311
78+
79+
[pytest]
80+
minversion = 6.0
81+
addopts = -ra -q
82+
testpaths =
83+
tests
84+
85+
[testenv]
86+
deps =
87+
-e ./[test]
88+
commands = pytest {posargs}
89+
90+
[testenv:flake8]
91+
deps =
92+
flake8
93+
commands =
94+
flake8 --ignore=E501,E402,F401 src/undate/ tests/
95+
96+
[testenv:coverage]
97+
deps =
98+
-e ./[test]
99+
commands =
100+
pytest --cov=./ --cov-report=xml
101+
102+
[testenv:docs]
103+
description = invoke sphinx-build to build the HTML docs
104+
# NOTE: base python should match whatever we're using in GitHub Actions
105+
basepython = python3.10
106+
deps =
107+
-e ./[docs]
108+
commands = sphinx-build -d "{toxworkdir}/docs_doctree" docs "{toxworkdir}/docs_out" --color -W -bhtml {posargs}
109+
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'

src/undate/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.0.dev"
1+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)