Skip to content

Commit a686be0

Browse files
authored
Merge pull request #4326 from tybug/fix-readme-job
Move build to pyproject.toml
2 parents edd2a75 + 596a22f commit a686be0

File tree

17 files changed

+216
-232
lines changed

17 files changed

+216
-232
lines changed

.github/workflows/main.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ jobs:
257257
CFLAGS=-g2 LDFLAGS=-g2 pyodide build
258258
- name: Set up Pyodide venv and install dependencies
259259
run: |
260-
pip install --upgrade setuptools pip wheel
261-
python hypothesis-python/setup.py bdist_wheel
260+
pip install --upgrade setuptools pip wheel build
261+
python -m build --wheel hypothesis-python --outdir dist/
262262
pip download --dest=dist/ hypothesis-python/ pytest tzdata # fetch all the wheels
263263
264264
rm dist/packaging-*.whl # fails with `invalid metadata entry 'name'`
@@ -312,5 +312,4 @@ jobs:
312312
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_TOKEN }}
313313
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
314314
run: |
315-
cp README.md hypothesis-python/
316315
TASK=${{ matrix.task }} ./build.sh

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<img src="./brand/dragonfly-rainbow.svg" width="300">
2+
<img src="https://raw.githubusercontent.com/HypothesisWorks/hypothesis/master/brand/dragonfly-rainbow.svg" width="300">
33
</div>
44

55
# Hypothesis

hypothesis-python/MANIFEST.in

-2
This file was deleted.

hypothesis-python/README.md

+1-47
Original file line numberDiff line numberDiff line change
@@ -1,47 +1 @@
1-
<div align="center">
2-
<img src="./brand/dragonfly-rainbow.svg" width="300">
3-
</div>
4-
5-
# Hypothesis
6-
7-
* [Website](https://hypothesis.works/)
8-
* [Documentation](https://hypothesis.readthedocs.io/en/latest/)
9-
* [Source code](https://github.com/hypothesisWorks/hypothesis/)
10-
* [Contributing](https://github.com/HypothesisWorks/hypothesis/blob/master/CONTRIBUTING.rst)
11-
* [Community](https://hypothesis.readthedocs.io/en/latest/community.html)
12-
13-
Hypothesis is the property-based testing library for Python. A property-based test asserts something for *all* inputs, and lets Hypothesis generate them — including inputs you may not have thought of.
14-
15-
```python
16-
from hypothesis import given, strategies as st
17-
18-
19-
@given(st.lists(st.integers() | st.floats()))
20-
def test_matches_builtin(ls):
21-
assert sorted(ls) == my_sort(ls)
22-
```
23-
24-
Additionally, when a property fails, Hypothesis doesn't just report any failing example — it reports the simplest possible one. This makes property-based tests a powerful tool for debugging, as well as testing.
25-
26-
For instance,
27-
28-
```python
29-
def my_sort(ls):
30-
return list(reversed(sorted(ls, reverse=True)))
31-
```
32-
33-
fails with:
34-
35-
```
36-
Falsifying example: test_matches_builtin(ls=[0, math.nan])
37-
```
38-
39-
### Installation
40-
41-
To install Hypothesis:
42-
43-
```
44-
pip install hypothesis
45-
```
46-
47-
There are also [optional extras available](https://hypothesis.readthedocs.io/en/latest/extras.html).
1+
The Hypothesis python readme has moved to [the main readme](../README.md)!

hypothesis-python/docs/packaging.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ Hypothesis has *mandatory* dependencies on the following libraries:
4545

4646
Hypothesis has *optional* dependencies on the following libraries:
4747

48-
.. literalinclude:: ../setup.py
49-
:prepend: extras_require = {
50-
:start-after: extras = {
51-
:end-before: }
52-
:append: }
48+
.. literalinclude:: ../pyproject.toml
49+
:prepend: [project.optional-dependencies]
50+
:start-after: [project.optional-dependencies]
51+
:end-before: # Avoid changing this by hand
5352

5453
The way this works when installing Hypothesis normally is that these features become available if the relevant
5554
library is installed.

hypothesis-python/docs/strategies.rst

+13-11
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ test is using Hypothesis:
134134

135135
.. _entry-points:
136136

137-
--------------------------------------------------
138-
Hypothesis integration via setuptools entry points
139-
--------------------------------------------------
137+
---------------------------------------
138+
Hypothesis integration via entry points
139+
---------------------------------------
140140

141141
If you would like to ship Hypothesis strategies for a custom type - either as
142142
part of the upstream library, or as a third-party extension, there's a catch:
@@ -150,9 +150,9 @@ either
150150
- the user has to call a 'register the strategies' helper that you provide
151151
before running their tests
152152

153-
`Entry points <https://amir.rachum.com/blog/2017/07/28/python-entry-points/>`__
153+
`Entry points <https://setuptools.pypa.io/en/latest/userguide/entry_point.html>`__
154154
are Python's standard way of automating the latter: when you register a
155-
``"hypothesis"`` entry point in your ``setup.py``, we'll import and run it
155+
``"hypothesis"`` entry point in your ``pyproject.toml``, we'll import and run it
156156
automatically when *hypothesis* is imported. Nothing happens unless Hypothesis
157157
is already in use, and it's totally seamless for downstream users!
158158

@@ -175,17 +175,19 @@ package that does all the Hypothesis-related setup work:
175175
176176
st.register_type_strategy(MyCustomType, st.integers(min_value=0))
177177
178-
and then tell ``setuptools`` that this is your ``"hypothesis"`` entry point:
178+
and then declare this as your ``"hypothesis"`` entry point:
179179

180-
.. code-block:: python
180+
.. code-block:: toml
181181
182-
# setup.py
182+
# pyproject.toml
183183
184184
# You can list a module to import by dotted name
185-
entry_points = {"hypothesis": ["_ = mymodule.a_submodule"]}
185+
[project.entry-points.hypothesis]
186+
_ = "mymodule.a_submodule"
186187
187-
# Or name a specific function too, and Hypothesis will call it for you
188-
entry_points = {"hypothesis": ["_ = mymodule:_hypothesis_setup_hook"]}
188+
# Or name a specific function, and Hypothesis will call it for you
189+
[project.entry-points.hypothesis]
190+
_ = "mymodule:_hypothesis_setup_hook"
189191
190192
And that's all it takes!
191193

hypothesis-python/pyproject.toml

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
[build-system]
2+
# require a recent setuptools for `license = ` support
3+
requires = ["setuptools >= 78.1.0", "wheel"]
4+
build-backend = "setuptools.build_meta"
5+
6+
[project]
7+
name = "hypothesis"
8+
# see [tool.setuptools.dynamic]
9+
dynamic = ["version"]
10+
authors = [
11+
{ name = "David R. MacIver and Zac Hatfield-Dodds", email = "[email protected]" }
12+
]
13+
description = "A library for property-based testing"
14+
# Avoid changing this by hand. This is automatically updated by update_changelog_and_version
15+
readme = {"text" = """<div align="center">
16+
<img src="https://raw.githubusercontent.com/HypothesisWorks/hypothesis/master/brand/dragonfly-rainbow.svg" width="300">
17+
</div>
18+
19+
# Hypothesis
20+
21+
* [Website](https://hypothesis.works/)
22+
* [Documentation](https://hypothesis.readthedocs.io/en/latest/)
23+
* [Source code](https://github.com/hypothesisWorks/hypothesis/)
24+
* [Contributing](https://github.com/HypothesisWorks/hypothesis/blob/master/CONTRIBUTING.rst)
25+
* [Community](https://hypothesis.readthedocs.io/en/latest/community.html)
26+
27+
Hypothesis is the property-based testing library for Python. A property-based test asserts something for *all* inputs, and lets Hypothesis generate them — including inputs you may not have thought of.
28+
29+
```python
30+
from hypothesis import given, strategies as st
31+
32+
33+
@given(st.lists(st.integers() | st.floats()))
34+
def test_matches_builtin(ls):
35+
assert sorted(ls) == my_sort(ls)
36+
```
37+
38+
Additionally, when a property fails, Hypothesis doesn't just report any failing example — it reports the simplest possible one. This makes property-based tests a powerful tool for debugging, as well as testing.
39+
40+
For instance,
41+
42+
```python
43+
def my_sort(ls):
44+
return list(reversed(sorted(ls, reverse=True)))
45+
```
46+
47+
fails with:
48+
49+
```
50+
Falsifying example: test_matches_builtin(ls=[0, math.nan])
51+
```
52+
53+
### Installation
54+
55+
To install Hypothesis:
56+
57+
```
58+
pip install hypothesis
59+
```
60+
61+
There are also [optional extras available](https://hypothesis.readthedocs.io/en/latest/extras.html).
62+
""", "content-type" = "text/markdown"}
63+
license = "MPL-2.0"
64+
requires-python = ">= 3.9"
65+
keywords = ["python", "testing", "fuzzing", "property-based-testing"]
66+
classifiers = [
67+
"Development Status :: 5 - Production/Stable",
68+
"Framework :: Hypothesis",
69+
"Framework :: Pytest",
70+
"Intended Audience :: Developers",
71+
"Operating System :: Unix",
72+
"Operating System :: POSIX",
73+
"Operating System :: Microsoft :: Windows",
74+
"Programming Language :: Python",
75+
"Programming Language :: Python :: 3",
76+
"Programming Language :: Python :: 3 :: Only",
77+
"Programming Language :: Python :: 3.9",
78+
"Programming Language :: Python :: 3.10",
79+
"Programming Language :: Python :: 3.11",
80+
"Programming Language :: Python :: 3.12",
81+
"Programming Language :: Python :: 3.13",
82+
"Programming Language :: Python :: Implementation :: CPython",
83+
"Programming Language :: Python :: Implementation :: PyPy",
84+
"Topic :: Education :: Testing",
85+
"Topic :: Software Development :: Testing",
86+
"Typing :: Typed",
87+
]
88+
89+
dependencies = [
90+
"attrs>=22.2.0",
91+
"exceptiongroup>=1.0.0; python_version<'3.11'",
92+
"sortedcontainers>=2.1.0,<3.0.0",
93+
]
94+
95+
[project.urls]
96+
homepage = "https://hypothesis.works"
97+
source = "https://github.com/HypothesisWorks/hypothesis"
98+
changelog = "https://hypothesis.readthedocs.io/en/latest/changes.html"
99+
documentation = "https://hypothesis.readthedocs.io"
100+
issues = "https://github.com/HypothesisWorks/hypothesis/issues"
101+
102+
[project.optional-dependencies]
103+
cli = ["click>=7.0", "black>=19.10b0", "rich>=9.0.0"]
104+
codemods = ["libcst>=0.3.16"]
105+
ghostwriter = ["black>=19.10b0"]
106+
pytz = ["pytz>=2014.1"]
107+
dateutil = ["python-dateutil>=1.4"]
108+
lark = ["lark>=0.10.1"] # probably still works with old `lark-parser` too
109+
numpy = ["numpy>=1.19.3"] # oldest with wheels for non-EOL Python (for now)
110+
pandas = ["pandas>=1.1"]
111+
pytest = ["pytest>=4.6"]
112+
dpcontracts = ["dpcontracts>=0.4"]
113+
redis = ["redis>=3.0.0"]
114+
crosshair = ["hypothesis-crosshair>=0.0.20", "crosshair-tool>=0.0.84"]
115+
# zoneinfo is an odd one: every dependency is platform-conditional.
116+
zoneinfo = ["tzdata>=2025.1; sys_platform == 'win32' or sys_platform == 'emscripten'"]
117+
# We only support Django versions with upstream support - see
118+
# https://www.djangoproject.com/download/#supported-versions
119+
# We also leave the choice of timezone library to the user, since it
120+
# might be zoneinfo or pytz depending on version and configuration.
121+
django = ["django>=4.2"]
122+
watchdog = ["watchdog>=4.0.0"]
123+
# Avoid changing this by hand. This is automatically updated by update_changelog_and_version
124+
all = ["black>=19.10b0", "click>=7.0", "crosshair-tool>=0.0.84", "django>=4.2", "dpcontracts>=0.4", "hypothesis-crosshair>=0.0.20", "lark>=0.10.1", "libcst>=0.3.16", "numpy>=1.19.3", "pandas>=1.1", "pytest>=4.6", "python-dateutil>=1.4", "pytz>=2014.1", "redis>=3.0.0", "rich>=9.0.0", "tzdata>=2025.1; sys_platform == 'win32' or sys_platform == 'emscripten'", "watchdog>=4.0.0"]
125+
126+
[tool.setuptools.dynamic]
127+
version = {attr = "hypothesis.version.__version__"}
128+
129+
[tool.setuptools.package-data]
130+
hypothesis = ["vendor/tlds-alpha-by-domain.txt"]
131+
132+
[project.scripts]
133+
hypothesis = "hypothesis.extra.cli:main"
134+
135+
[project.entry-points.pytest11]
136+
hypothesispytest = "_hypothesis_pytestplugin"

hypothesis-python/scripts/basic-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $PYTEST tests/typing_extensions/
3636
pip uninstall -y typing_extensions
3737

3838
pip install ".[lark]"
39-
pip install "$(grep -oE 'lark>=([0-9.]+)' ../hypothesis-python/setup.py | tr '>' =)"
39+
pip install "$(grep -m 1 -oE 'lark>=([0-9.]+)' ../hypothesis-python/pyproject.toml | tr '>' =)"
4040
$PYTEST -Wignore tests/lark/
4141
pip install "$(grep 'lark==' ../requirements/coverage.txt)"
4242
$PYTEST tests/lark/

hypothesis-python/scripts/other-tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $PYTEST tests/test_annotated_types.py
4040
pip uninstall -y annotated-types
4141

4242
pip install ".[lark]"
43-
pip install "$(grep -oE 'lark>=([0-9.]+)' ../hypothesis-python/setup.py | tr '>' =)"
43+
pip install "$(grep -m 1 -oE 'lark>=([0-9.]+)' ../hypothesis-python/pyproject.toml | tr '>' =)"
4444
$PYTEST -Wignore tests/lark/
4545
pip install "$(grep 'lark==' ../requirements/coverage.txt)"
4646
$PYTEST tests/lark/

hypothesis-python/setup.cfg

-3
This file was deleted.

0 commit comments

Comments
 (0)