Skip to content

Commit 508a51e

Browse files
committed
Modernize setuptools packaging and automate releases
1 parent 6f220ed commit 508a51e

File tree

15 files changed

+244
-174
lines changed

15 files changed

+244
-174
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ commit = True
44
tag = True
55
tag_name = {new_version}
66

7-
[bumpversion:file:testbook/_version.py]
7+
[bumpversion:file:pyproject.toml]

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: [3.6, 3.7, 3.8, 3.9, "3.10.0-rc.2"]
16+
python-version: [3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12]
1717
env:
1818
OS: ubuntu-latest
1919
PYTHON: "3.8"

.github/workflows/publish.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Publish testbook
2+
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m
19+
pip install
20+
build
21+
--user
22+
- name: Build a binary wheel and a source tarball
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: python-package-distributions
28+
path: dist/
29+
30+
publish-to-pypi:
31+
name: >-
32+
Publish Python 🐍 distribution 📦 to PyPI
33+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/testbook
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution 📦 to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
52+
github-release:
53+
name: >-
54+
Sign the Python 🐍 distribution 📦 with Sigstore
55+
and upload them to GitHub Release
56+
needs:
57+
- publish-to-pypi
58+
runs-on: ubuntu-latest
59+
60+
permissions:
61+
contents: write # IMPORTANT: mandatory for making GitHub Releases
62+
id-token: write # IMPORTANT: mandatory for sigstore
63+
64+
steps:
65+
- name: Download all the dists
66+
uses: actions/download-artifact@v3
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
- name: Sign the dists with Sigstore
71+
uses: sigstore/[email protected]
72+
with:
73+
inputs: >-
74+
./dist/*.tar.gz
75+
./dist/*.whl
76+
- name: Create GitHub Release
77+
env:
78+
GITHUB_TOKEN: ${{ github.token }}
79+
run: >-
80+
gh release create
81+
'${{ github.ref_name }}'
82+
--repo '${{ github.repository }}'
83+
--notes ""
84+
- name: Upload artifact signatures to GitHub Release
85+
env:
86+
GITHUB_TOKEN: ${{ github.token }}
87+
# Upload to GitHub Release using the `gh` CLI.
88+
# `dist/` contains the built packages, and the
89+
# sigstore-produced signatures and certificates.
90+
run: >-
91+
gh release upload
92+
'${{ github.ref_name }}' dist/**
93+
--repo '${{ github.repository }}'
94+
95+
publish-to-testpypi:
96+
name: Publish Python 🐍 distribution 📦 to TestPyPI
97+
needs:
98+
- build
99+
runs-on: ubuntu-latest
100+
101+
environment:
102+
name: testpypi
103+
url: https://test.pypi.org/p/testbook
104+
105+
permissions:
106+
id-token: write # IMPORTANT: mandatory for trusted publishing
107+
108+
steps:
109+
- name: Download all the dists
110+
uses: actions/download-artifact@v3
111+
with:
112+
name: python-package-distributions
113+
path: dist/
114+
- name: Publish distribution 📦 to TestPyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1
116+
with:
117+
repository-url: https://test.pypi.org/legacy/

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[![Build Status](https://github.com/nteract/testbook/workflows/CI/badge.svg)](https://github.com/nteract/testbook/actions)
22
[![image](https://codecov.io/github/nteract/testbook/coverage.svg?branch=master)](https://codecov.io/github/nteract/testbook?branch=master)
33
[![Documentation Status](https://readthedocs.org/projects/testbook/badge/?version=latest)](https://testbook.readthedocs.io/en/latest/?badge=latest)
4-
[![PyPI](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.org/project/testbook/)
5-
[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
6-
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
7-
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)
8-
[![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)
4+
[![image](https://img.shields.io/pypi/v/testbook.svg)](https://pypi.python.org/pypi/testbook)
5+
[![image](https://img.shields.io/pypi/l/testbook.svg)](https://github.com/astral-sh/testbook/blob/main/LICENSE)
6+
[![image](https://img.shields.io/pypi/pyversions/testbook.svg)](https://pypi.python.org/pypi/testbook)
97
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
108

119
# testbook

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Prerequisites
44

55
- First check that the CHANGELOG is up to date for the next release version
6-
- Ensure dev requirements are installed `pip install -r requirements-dev.txt`
6+
- Ensure dev requirements are installed `pip install ".[dev]"`
77

88
## Push to GitHub
99

@@ -19,6 +19,6 @@ git push upstream && git push upstream --tags
1919
```bash
2020
rm -rf dist/*
2121
rm -rf build/*
22-
python setup.py bdist_wheel
22+
python -m build
2323
twine upload dist/*
2424
```

docs/requirements-doc.txt

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

pyproject.toml

Lines changed: 116 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,132 @@
1-
# Example configuration for Black.
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
23

3-
# NOTE: you have to use single-quoted strings in TOML for regular expressions.
4-
# It's the equivalent of r-strings in Python. Multiline strings are treated as
5-
# verbose regular expressions by Black. Use [ ] to denote a significant space
6-
# character.
4+
requires = [ "setuptools" ]
5+
6+
[project]
7+
name = "testbook_rohitsanjay"
8+
version = "0.4.2"
9+
description = "A unit testing framework for Jupyter Notebooks"
10+
readme = "README.md"
11+
keywords = [ "jupyter", "notebook", "nteract", "unit-testing" ]
12+
license = { file = "LICENSE" }
13+
maintainers = [
14+
{ name = "Nteract Contributors", email = "[email protected]" },
15+
{ name = "Rohit Sanjay", email = "[email protected]" },
16+
{ name = "Matthew Seal", email = "[email protected]" },
17+
]
18+
authors = [
19+
{ name = "Nteract Contributors", email = "[email protected]" },
20+
{ name = "Rohit Sanjay", email = "[email protected]" },
21+
{ name = "Matthew Seal", email = "[email protected]" },
22+
]
23+
requires-python = ">=3.6"
24+
25+
classifiers = [
26+
"Intended Audience :: Developers",
27+
"License :: OSI Approved :: BSD License",
28+
"Programming Language :: Python",
29+
"Programming Language :: Python :: 3 :: Only",
30+
"Programming Language :: Python :: 3.6",
31+
"Programming Language :: Python :: 3.7",
32+
"Programming Language :: Python :: 3.8",
33+
"Programming Language :: Python :: 3.9",
34+
"Programming Language :: Python :: 3.10",
35+
"Programming Language :: Python :: 3.11",
36+
"Programming Language :: Python :: 3.12",
37+
"Topic :: Software Development :: Testing",
38+
"Topic :: Software Development :: Testing :: Mocking",
39+
"Topic :: Software Development :: Testing :: Unit",
40+
]
41+
dependencies = [
42+
"nbclient>=0.4",
43+
"nbformat>=5.0.4",
44+
]
45+
optional-dependencies.dev = [
46+
"black; python_version>='3.6'",
47+
"bumpversion",
48+
"check-manifest",
49+
"codecov",
50+
"coverage",
51+
"flake8",
52+
"ipykernel",
53+
"ipython",
54+
"ipywidgets",
55+
"pandas",
56+
"pip>=18.1",
57+
"pytest>=4.1",
58+
"pytest-cov>=2.6.1",
59+
"setuptools>=38.6",
60+
"tox",
61+
"build",
62+
"twine>=1.11",
63+
"xmltodict",
64+
]
65+
optional-dependencies.test = [
66+
"myst-parser==0.9.1",
67+
"sphinx>=1.7,<3",
68+
"sphinx-book-theme==0.0.35",
69+
]
70+
urls.Documentation = "https://testbook.readthedocs.io"
71+
urls.Funding = "https://nteract.io"
72+
urls.Issues = "https://github.com/nteract/testbook/issues"
73+
urls.Repository = "https://github.com/nteract/testbook/"
774

875
[tool.black]
976
line-length = 100
10-
include = '\.pyi?$'
1177
exclude = '''
1278
/(
1379
\.git
14-
| \.hg
1580
| \.mypy_cache
1681
| \.tox
1782
| \.venv
1883
| _build
19-
| buck-out
2084
| build
2185
| dist
22-
23-
# The following are specific to Black, you probably don't want those.
24-
| blib2to3
25-
| tests/data
26-
| profiling
2786
)/
2887
'''
2988
skip-string-normalization = true
89+
90+
[tool.flake8]
91+
exclude = "__init__.py"
92+
ignore = [
93+
"E20", # Extra space in brackets
94+
"E231",
95+
"E241", # Multiple spaces around ","
96+
"E26", # Comments
97+
"E4", # Import formatting
98+
"E721", # Comparing types instead of isinstance
99+
"E731", # Assigning lambda expression
100+
]
101+
max-line-length = 120
102+
103+
# Not sure I need this?
104+
# [tool.bdist_wheel]
105+
# universal = 0
106+
107+
[tool.pytest.ini_options]
108+
filterwarnings = "always"
109+
testpaths = [
110+
"testbook/tests/",
111+
]
112+
113+
[tool.coverage.run]
114+
branch = false
115+
omit = [
116+
"testbook/tests/*",
117+
"testbook/_version.py",
118+
]
119+
120+
[tool.coverage.report]
121+
exclude_lines = [
122+
"if self\\.debug:",
123+
"pragma: no cover",
124+
"raise AssertionError",
125+
"raise NotImplementedError",
126+
"if __name__ == '__main__':",
127+
]
128+
ignore_errors = true
129+
omit = [
130+
"testbook/tests/*",
131+
"testbook/_version.py",
132+
]

pytest.ini

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

requirements-dev.txt

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

requirements.txt

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

setup.cfg

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

0 commit comments

Comments
 (0)