Skip to content

Commit 2a47c4e

Browse files
committed
update most setup.py references
1 parent c40571f commit 2a47c4e

File tree

7 files changed

+30
-28
lines changed

7 files changed

+30
-28
lines changed

hypothesis-python/docs/strategies.rst

+12-10
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

180180
.. code-block:: python
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
{ name = "David R. MacIver and Zac Hatfield-Dodds", email = "[email protected]" }
1212
]
1313
description = "A library for property-based testing"
14-
# Do not change. This is automatically updated by update_changelog_and_version
14+
# Avoid changing this by hand. This is automatically updated by update_changelog_and_version
1515
readme = {"text" = """<div align="center">
1616
<img src="https://raw.githubusercontent.com/HypothesisWorks/hypothesis/master/brand/dragonfly-rainbow.svg" width="300">
1717
</div>
@@ -61,7 +61,7 @@ pip install hypothesis
6161
There are also [optional extras available](https://hypothesis.readthedocs.io/en/latest/extras.html).
6262
""", "content-type" = "text/markdown"}
6363
license = "MPL-2.0"
64-
requires-python = ">=3.9"
64+
requires-python = ">= 3.9"
6565
keywords = ["python", "testing", "fuzzing", "property-based-testing"]
6666
classifiers = [
6767
"Development Status :: 5 - Production/Stable",
@@ -120,7 +120,7 @@ zoneinfo = ["tzdata>=2025.1; sys_platform == 'win32' or sys_platform == 'emscrip
120120
# might be zoneinfo or pytz depending on version and configuration.
121121
django = ["django>=4.2"]
122122
watchdog = ["watchdog>=4.0.0"]
123-
# Do not change. This is automatically updated by update_changelog_and_version
123+
# Avoid changing this by hand. This is automatically updated by update_changelog_and_version
124124
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"]
125125

126126
[tool.setuptools.dynamic]

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 -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 -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/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ deps=
5353
allowlist_externals =
5454
bash
5555
commands=
56-
bash -c "pip install --only-binary=:all: numpy==$(grep 'numpy>=' setup.py | grep -oE '[0-9.]+')"
56+
bash -c "pip install --only-binary=:all: numpy==$(grep 'numpy>=' pyproject.toml | grep -oE '[0-9.]+')"
5757
python -bb -X dev -m pytest tests/numpy/ -n auto
5858

5959
# This test job runs against the nightly version of `numpy`

tooling/src/hypothesistooling/__main__.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def compile_requirements(*, upgrade=False):
252252
"--resolver=backtracking", # new pip resolver, default in pip-compile 7+
253253
*extra,
254254
str(f),
255-
"hypothesis-python/setup.py",
255+
"hypothesis-python/pyproject.toml",
256256
"--output-file",
257257
str(out_file),
258258
cwd=tools.ROOT,
@@ -288,8 +288,8 @@ def update_python_versions():
288288
# (plus some special cases for the `t` suffix for free-threading builds)
289289
stable = re.compile(r".*3\.\d+.\d+t?$")
290290
min_minor_version = re.search(
291-
r'python_requires=">= ?3.(\d+)"',
292-
Path("hypothesis-python/setup.py").read_text(encoding="utf-8"),
291+
r'requires-python = ">= ?3.(\d+)"',
292+
Path("hypothesis-python/pyproject.toml").read_text(encoding="utf-8"),
293293
).group(1)
294294
best = {}
295295
for line in map(str.strip, result.splitlines()):
@@ -350,14 +350,14 @@ def update_django_versions():
350350
thisfile.write_text(after, encoding="utf-8")
351351
pip_tool("shed", str(thisfile))
352352

353-
# Update the minimum version in setup.py
354-
setup_py = hp.BASE_DIR / "setup.py"
353+
# Update the minimum version in pyproject.toml
354+
pyproject_toml = hp.BASE_DIR / "pyproject.toml"
355355
content = re.sub(
356356
r"django>=\d+\.\d+",
357357
f"django>={min(versions, key=float)}",
358-
setup_py.read_text(encoding="utf-8"),
358+
pyproject_toml.read_text(encoding="utf-8"),
359359
)
360-
setup_py.write_text(content, encoding="utf-8")
360+
pyproject_toml.write_text(content, encoding="utf-8")
361361

362362
# Automatically sync ci_version with the version in build.sh
363363
tox_ini = hp.BASE_DIR / "tox.ini"
@@ -417,13 +417,13 @@ def update_vendored_files():
417417
# Always require the most recent version of tzdata - we don't need to worry about
418418
# pre-releases because tzdata is a 'latest data' package (unlike pyodide-build).
419419
# Our crosshair extra is research-grade, so we require latest versions there too.
420-
setup = pathlib.Path(hp.BASE_DIR, "setup.py")
421-
new = setup.read_text(encoding="utf-8")
420+
pyproject_toml = pathlib.Path(hp.BASE_DIR, "pyproject.toml")
421+
new = pyproject_toml.read_text(encoding="utf-8")
422422
for pkgname in ("tzdata", "crosshair-tool", "hypothesis-crosshair"):
423423
pkg_url = f"https://pypi.org/pypi/{pkgname}/json"
424424
pkg_version = requests.get(pkg_url).json()["info"]["version"]
425425
new = re.sub(rf"{pkgname}>=([a-z0-9.]+)", f"{pkgname}>={pkg_version}", new)
426-
setup.write_text(new, encoding="utf-8")
426+
pyproject_toml.write_text(new, encoding="utf-8")
427427

428428

429429
def has_diff(file_or_directory):
@@ -496,7 +496,7 @@ def run_tox(task, version, *args):
496496

497497
# update_python_versions(), above, keeps the contents of this dict up to date.
498498
# When a version is added or removed, manually update the env lists in tox.ini and
499-
# workflows/main.yml, and the `Programming Language ::` specifiers in setup.py
499+
# workflows/main.yml, and the `Programming Language ::` specifiers in pyproject.toml
500500
PYTHONS = {
501501
"3.9": "3.9.21",
502502
"3.10": "3.10.16",

whole_repo_tests/test_ci_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_python_versions_are_tested_in_ci(version):
3434
def test_python_versions_are_in_trove_classifiers():
3535
got_classifiers = {
3636
line.strip(' ",\n')
37-
for line in Path("hypothesis-python/setup.py")
37+
for line in Path("hypothesis-python/pyproject.toml")
3838
.read_text(encoding="utf-8")
3939
.splitlines()
4040
if "Programming Language :: Python :: 3." in line

0 commit comments

Comments
 (0)