Skip to content

Commit 129daf2

Browse files
committed
Make it build on python 3.13 with cython 3.1.
1 parent 5689bae commit 129daf2

22 files changed

Lines changed: 38097 additions & 30753 deletions

.cookiecutterrc

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,61 @@
1-
# Generated by cookiepatcher, a small shim around cookiecutter (pip install cookiepatcher)
1+
# This file exists so you can easily regenerate your project.
2+
#
3+
# `cookiepatcher` is a convenient shim around `cookiecutter`
4+
# for regenerating projects (it will generate a .cookiecutterrc
5+
# automatically for any template). To use it:
6+
#
7+
# pip install cookiepatcher
8+
# cookiepatcher gh:ionelmc/cookiecutter-pylibrary python-hunter
9+
#
10+
# See:
11+
# https://pypi.org/project/cookiepatcher
12+
#
13+
# Alternatively, you can run:
14+
#
15+
# cookiecutter --overwrite-if-exists --config-file=python-hunter/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary
216

317
default_context:
4-
c_extension_optional: 'yes'
5-
c_extension_support: cython
6-
codacy: 'no'
7-
codacy_projectid: '-'
8-
codeclimate: 'no'
9-
codecov: 'yes'
10-
command_line_interface: argparse
11-
command_line_interface_bin_name: hunter-trace
12-
coveralls: 'no'
13-
distribution_name: hunter
14-
email: contact@ionelmc.ro
15-
formatter_quote_style: single
16-
full_name: Ionel Cristian Mărieș
17-
function_name: compute
18-
github_actions: 'yes'
19-
github_actions_osx: 'yes'
20-
github_actions_windows: 'yes'
21-
license: BSD 2-Clause License
22-
module_name: core
23-
package_name: hunter
24-
pre_commit: 'yes'
25-
project_name: Hunter
26-
project_short_description: Hunter is a flexible code tracing toolkit, not for measuring coverage, but for debugging, logging, inspection and other nefarious purposes. It has a simple Python API and a convenient terminal API (see `Environment variable activation <env-var-activation_>`_).
27-
pypi_badge: 'yes'
28-
pypi_disable_upload: 'no'
29-
release_date: '2023-04-26'
30-
repo_hosting: github.com
31-
repo_hosting_domain: github.com
32-
repo_main_branch: master
33-
repo_name: python-hunter
34-
repo_username: ionelmc
35-
scrutinizer: 'no'
36-
setup_py_uses_setuptools_scm: 'yes'
37-
sphinx_docs: 'yes'
38-
sphinx_docs_hosting: https://python-hunter.readthedocs.io/
39-
sphinx_doctest: 'no'
40-
sphinx_theme: furo
41-
test_matrix_separate_coverage: 'yes'
42-
tests_inside_package: 'no'
43-
version: 3.7.0
44-
version_manager: bump2version
45-
website: https://blog.ionelmc.ro
46-
year_from: '2015'
47-
year_to: '2024'
18+
c_extension_optional: "yes"
19+
c_extension_support: "cython"
20+
codacy: "no"
21+
codacy_projectid: "-"
22+
codeclimate: "no"
23+
codecov: "yes"
24+
command_line_interface: "argparse"
25+
command_line_interface_bin_name: "hunter-trace"
26+
coveralls: "no"
27+
distribution_name: "hunter"
28+
email: "contact@ionelmc.ro"
29+
formatter_quote_style: "single"
30+
full_name: "Ionel Cristian Mărieș"
31+
function_name: "compute"
32+
github_actions: "yes"
33+
github_actions_osx: "yes"
34+
github_actions_windows: "yes"
35+
license: "BSD 2-Clause License"
36+
module_name: "core"
37+
package_name: "hunter"
38+
pre_commit: "yes"
39+
project_name: "Hunter"
40+
project_short_description: "Hunter is a flexible code tracing toolkit, not for measuring coverage, but for debugging, logging, inspection and other nefarious purposes. It has a simple Python API and a convenient terminal API (see `Environment variable activation <env-var-activation_>`_)."
41+
pypi_badge: "yes"
42+
pypi_disable_upload: "no"
43+
release_date: "2024-05-02"
44+
repo_hosting: "github.com"
45+
repo_hosting_domain: "github.com"
46+
repo_main_branch: "master"
47+
repo_name: "python-hunter"
48+
repo_username: "ionelmc"
49+
scrutinizer: "no"
50+
setup_py_uses_setuptools_scm: "yes"
51+
sphinx_docs: "yes"
52+
sphinx_docs_hosting: "https://python-hunter.readthedocs.io/"
53+
sphinx_doctest: "no"
54+
sphinx_theme: "furo"
55+
test_matrix_separate_coverage: "yes"
56+
tests_inside_package: "no"
57+
version: "3.7.0"
58+
version_manager: "bump2version"
59+
website: "https://blog.ionelmc.ro"
60+
year_from: "2015"
61+
year_to: "2025"

.pre-commit-config.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ exclude: '^(.tox/|ci/templates/|src/hunter.(pth|embed)$|src/hunter/vendor/|.bump
66
# Note the order is intentional to avoid multiple passes of the hooks
77
repos:
88
- repo: https://github.com/astral-sh/ruff-pre-commit
9-
rev: v0.4.2
9+
rev: v0.12.2
1010
hooks:
1111
- id: ruff
12-
args: [--fix, --exit-non-zero-on-fix, --show-fixes, --unsafe-fixes]
13-
- repo: https://github.com/psf/black
14-
rev: 24.4.2
15-
hooks:
16-
- id: black
12+
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
13+
- id: ruff-format
1714
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.6.0
15+
rev: v5.0.0
1916
hooks:
2017
- id: trailing-whitespace
2118
exclude_types:
@@ -28,6 +25,6 @@ repos:
2825
- id: debug-statements
2926
exclude: '^tests/sample*|src/hunter/actions.py'
3027
- repo: https://github.com/MarcoGorelli/cython-lint
31-
rev: v0.16.2
28+
rev: v0.16.7
3229
hooks:
3330
- id: cython-lint

ci/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
virtualenv>=20.4.7
22
pip>=19.1.1
33
setuptools>=18.0.1
4-
six>=1.14.0
54
tox
65
twine

ci/templates/.github/workflows/github-actions.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
!matrix.cibw_build
110110
run: >
111111
tox -e {{ '${{ matrix.tox_env }}' }} -v
112-
- uses: codecov/codecov-action@v3
112+
- uses: codecov/codecov-action@v5
113113
if: matrix.cover
114114
with:
115115
verbose: true
@@ -130,7 +130,10 @@ jobs:
130130
if: {{ '${{ always() }}' }}
131131
runs-on: ubuntu-latest
132132
steps:
133-
- uses: codecov/codecov-action@v3
133+
- uses: actions/upload-artifact/merge@v4
134+
with:
135+
name: all-wheels
136+
- uses: codecov/codecov-action@v5
134137
with:
135138
CODECOV_TOKEN: {% raw %}${{ secrets.CODECOV_TOKEN }}{% endraw %}
136139
{{ '' }}

docs/conf.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
source_suffix = '.rst'
1818
master_doc = 'index'
1919
project = 'Hunter'
20-
year = '2015-2024'
20+
year = '2015-2025'
2121
author = 'Ionel Cristian Mărieș'
2222
copyright = f'{year}, {author}'
2323
try:
@@ -50,7 +50,3 @@
5050
napoleon_use_ivar = True
5151
napoleon_use_rtype = False
5252
napoleon_use_param = False
53-
54-
autosummary_generate = True
55-
56-
autosectionlabel_prefix_document = True

pyproject.toml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ backend-path = ["build_backend"]
1111
extend-exclude = ["static", "ci/templates"]
1212
line-length = 140
1313
src = ["src", "tests"]
14-
target-version = "py38"
14+
target-version = "py39"
15+
1516
[tool.cython-lint]
1617
max-line-length = 140
1718

@@ -26,6 +27,7 @@ ignore = [
2627
"S307",
2728
"S308", # flake8-bandit suspicious-mark-safe-usage
2829
"E501", # pycodestyle line-too-long
30+
"PLC0415", # import-outside-top-level
2931
]
3032
select = [
3133
"B", # flake8-bugbear
@@ -40,7 +42,6 @@ select = [
4042
"PLC", # pylint convention
4143
"PLE", # pylint errors
4244
"PT", # flake8-pytest-style
43-
"Q", # flake8-quotes
4445
"RSE", # flake8-raise
4546
"RUF", # ruff-specific rules
4647
"S", # flake8-bandit
@@ -52,15 +53,10 @@ select = [
5253
fixture-parentheses = false
5354
mark-parentheses = false
5455

55-
[tool.ruff.lint.flake8-quotes]
56-
inline-quotes = "single"
57-
5856
[tool.ruff.lint.isort]
5957
extra-standard-library = ["opcode"]
6058
forced-separate = ["conftest"]
6159
force-single-line = true
6260

63-
[tool.black]
64-
line-length = 140
65-
target-version = ["py38"]
66-
skip-string-normalization = true
61+
[tool.ruff.format]
62+
quote-style = "single"

setup.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pathlib import Path
77

88
from setuptools import Extension
9-
from setuptools import find_packages
9+
from setuptools import find_namespace_packages
1010
from setuptools import setup
1111
from setuptools.command.build import build
1212
from setuptools.command.build_ext import build_ext
@@ -23,14 +23,23 @@
2323
Cython = None
2424

2525
# Enable code coverage for C code: we cannot use CFLAGS=-coverage in tox.ini, since that may mess with compiling
26-
# dependencies (e.g. numpy). Therefore we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
26+
# dependencies (e.g. numpy). Therefore, we set SETUPPY_CFLAGS=-coverage in tox.ini and copy it to CFLAGS here (after
2727
# deps have been safely installed).
2828
if 'TOX_ENV_NAME' in os.environ and os.environ.get('SETUPPY_EXT_COVERAGE') == 'yes':
2929
CFLAGS = os.environ['CFLAGS'] = '-DCYTHON_TRACE=1'
3030
LFLAGS = os.environ['LFLAGS'] = ''
3131
else:
3232
CFLAGS = ''
3333
LFLAGS = ''
34+
35+
allow_extensions = True
36+
if '__pypy__' in sys.builtin_module_names:
37+
print('NOTICE: C extensions disabled on PyPy (would be broken)!')
38+
allow_extensions = False
39+
if os.environ.get('SETUPPY_FORCE_PURE'):
40+
print('NOTICE: C extensions disabled (SETUPPY_FORCE_PURE)!')
41+
allow_extensions = False
42+
3443
pth_file = str(Path(__file__).parent.joinpath('src', 'hunter.pth'))
3544

3645

@@ -70,8 +79,6 @@ class OptionalBuildExt(build_ext):
7079

7180
def run(self):
7281
try:
73-
if os.environ.get('SETUPPY_FORCE_PURE'):
74-
raise Exception('C extensions disabled (SETUPPY_FORCE_PURE)!')
7582
super().run()
7683
except Exception as e:
7784
self._unavailable(e)
@@ -121,29 +128,30 @@ def read(*names, **kwargs):
121128
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
122129
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst')),
123130
),
131+
long_description_content_type='text/x-rst',
124132
author='Ionel Cristian Mărieș',
125133
author_email='contact@ionelmc.ro',
126134
url='https://github.com/ionelmc/python-hunter',
127-
packages=find_packages('src'),
135+
packages=find_namespace_packages('src'),
128136
package_dir={'': 'src'},
129137
py_modules=[path.stem for path in Path('src').glob('*.py')],
138+
include_package_data=True,
130139
zip_safe=False,
131140
classifiers=[
132141
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
133142
'Development Status :: 5 - Production/Stable',
134143
'Intended Audience :: Developers',
135-
'License :: OSI Approved :: BSD License',
136144
'Operating System :: Unix',
137145
'Operating System :: POSIX',
138146
'Operating System :: Microsoft :: Windows',
139147
'Programming Language :: Python',
140148
'Programming Language :: Python :: 3',
141149
'Programming Language :: Python :: 3 :: Only',
142-
'Programming Language :: Python :: 3.8',
143150
'Programming Language :: Python :: 3.9',
144151
'Programming Language :: Python :: 3.10',
145152
'Programming Language :: Python :: 3.11',
146153
'Programming Language :: Python :: 3.12',
154+
'Programming Language :: Python :: 3.13',
147155
'Programming Language :: Python :: Implementation :: CPython',
148156
'Programming Language :: Python :: Implementation :: PyPy',
149157
'Topic :: Utilities',
@@ -163,7 +171,7 @@ def read(*names, **kwargs):
163171
'code',
164172
'source',
165173
],
166-
python_requires='>=3.8',
174+
python_requires='>=3.9',
167175
install_requires=[],
168176
extras_require={
169177
':platform_system != "Windows"': ['manhole >= 1.5'],
@@ -190,19 +198,17 @@ def read(*names, **kwargs):
190198
'develop': DevelopWithPTH,
191199
'build_ext': OptionalBuildExt,
192200
},
193-
ext_modules=(
194-
[]
195-
if hasattr(sys, 'pypy_version_info')
196-
else [
197-
Extension(
198-
str(path.relative_to('src').with_suffix('')).replace(os.sep, '.'),
199-
sources=[str(path)],
200-
extra_compile_args=CFLAGS.split(),
201-
extra_link_args=LFLAGS.split(),
202-
include_dirs=[str(path.parent)],
203-
)
204-
for path in Path('src').glob('**/*.pyx' if Cython else '**/*.c')
205-
]
206-
),
207-
distclass=BinaryDistribution,
201+
ext_modules=[
202+
Extension(
203+
str(path.relative_to('src').with_suffix('')).replace(os.sep, '.'),
204+
sources=[str(path)],
205+
extra_compile_args=CFLAGS.split(),
206+
extra_link_args=LFLAGS.split(),
207+
include_dirs=[str(path.parent)],
208+
)
209+
for path in Path('src').glob('**/*.pyx' if Cython else '**/*.c')
210+
]
211+
if allow_extensions
212+
else [],
213+
distclass=BinaryDistribution if allow_extensions else None,
208214
)

src/hunter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def Backlog(*conditions, **kwargs):
341341
vars = kwargs.pop('vars', False)
342342
if not conditions and not kwargs:
343343
raise TypeError(
344-
'Backlog needs at least 1 condition ' "(it doesn't have any effect without one besides making everything incredibly slow)."
344+
"Backlog needs at least 1 condition (it doesn't have any effect without one besides making everything incredibly slow)."
345345
)
346346
return _Backlog(
347347
_merge(*conditions, **kwargs),

0 commit comments

Comments
 (0)