Skip to content

Commit 997dfc6

Browse files
Fixes for numpy-2.0 (#81)
This patch fixes a couple of deprecations/dependency changes. * Resolved issues with numpy-2.0: replaced numpy.VisibleDeprecationWarning, upgraded pybind11 to 2.13.2 * Fixed issues with clang-format, which destroyed the jupyter notebooks * Updated CI scripts analog to iminuit * Dropped support for python-3.8 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 87e8add commit 997dfc6

File tree

18 files changed

+159
-123
lines changed

18 files changed

+159
-123
lines changed

.clang-format-ignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docs/examples/*
2+
extern/*

.github/workflows/docs.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ jobs:
1414
build:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v3
18-
with:
19-
submodules: true
20-
fetch-depth: 0 # needed for setuptools_scm
21-
# must come after checkout
22-
- uses: hendrikmuhs/[email protected]
23-
with:
24-
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
25-
- uses: actions/setup-python@v4
26-
with:
27-
python-version: "3.9"
28-
- run: sudo apt-get install pandoc
29-
- run: python -m pip install --prefer-binary -v .[doc]
30-
- run: python -m ipykernel install --user --name python3
31-
- run: python docs/build.py
32-
- uses: actions/upload-pages-artifact@v1
33-
with:
34-
path: 'docs/_build/html'
17+
- uses: actions/checkout@v3
18+
with:
19+
submodules: true
20+
fetch-depth: 0 # needed for setuptools_scm
21+
# must come after checkout
22+
- uses: hendrikmuhs/[email protected]
23+
with:
24+
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.11"
28+
- run: sudo apt-get install pandoc
29+
- run: python -m pip install --prefer-binary -v .[doc]
30+
- run: python -m ipykernel install --user --name python3
31+
- run: python docs/build.py
32+
- uses: actions/upload-pages-artifact@v1
33+
with:
34+
path: "docs/_build/html"
3535

3636
deploy:
3737
if: github.ref_type == 'tag' || github.ref_name == 'main'
@@ -49,5 +49,5 @@ jobs:
4949
runs-on: ubuntu-latest
5050

5151
steps:
52-
- uses: actions/configure-pages@v2
53-
- uses: actions/deploy-pages@v1
52+
- uses: actions/configure-pages@v2
53+
- uses: actions/deploy-pages@v1

.github/workflows/test.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ name: Test
33
on:
44
pull_request:
55
paths-ignore:
6-
- 'docs/**'
7-
- '*.rst'
8-
- '*.md'
6+
- "docs/**"
7+
- "*.rst"
8+
- "*.md"
99
workflow_dispatch:
1010

1111
concurrency:
@@ -22,27 +22,31 @@ jobs:
2222
# version number must be string, otherwise 3.10 becomes 3.1
2323
- os: windows-latest
2424
python-version: "3.11"
25-
- os: macos-13
26-
python-version: "3.8"
25+
installs: "numpy>=2"
26+
- os: macos-14
27+
python-version: "3.9"
28+
installs: "numpy==1.21.0"
2729
- os: ubuntu-latest
28-
python-version: "pypy-3.8"
30+
python-version: "3.13"
31+
installs: "'numpy>=2' scipy matplotlib"
2932
fail-fast: false
3033
steps:
31-
- uses: actions/checkout@v3
32-
with:
33-
submodules: true
34-
fetch-depth: 3
35-
# must come after checkout
36-
- uses: hendrikmuhs/[email protected]
37-
with:
38-
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
39-
- uses: actions/setup-python@v4
40-
with:
41-
python-version: ${{ matrix.python-version }}
42-
- run: python -m pip install --upgrade pip
43-
- run: python -m pip install --prefer-binary -v .[test]
44-
env:
45-
DEBUG: 1
46-
- uses: ts-graphviz/setup-graphviz@v1
47-
if: ${{ matrix.os != 'macos-13' }}
48-
- run: python -m pytest
34+
- uses: actions/checkout@v4
35+
with:
36+
submodules: true
37+
fetch-depth: 3
38+
# must come after checkout
39+
- uses: hendrikmuhs/[email protected]
40+
with:
41+
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
42+
- uses: astral-sh/setup-uv@v3
43+
- uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
allow-prereleases: true
47+
- uses: ts-graphviz/setup-graphviz@v1
48+
if: ${{ matrix.os != 'macos-13' }}
49+
- run: uv pip install --system .[test] ${{ matrix.installs }}
50+
env:
51+
DEBUG: 1
52+
- run: python -m pytest

.github/workflows/wheels.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Wheels
33
on:
44
push:
55
tags:
6-
- '**'
6+
- "**"
77
workflow_dispatch:
88

99
concurrency:
@@ -22,40 +22,33 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
os: [ubuntu-latest, windows-latest, macos-13]
26-
arch: [auto, aarch64, universal2]
27-
py: [cp38, cp39, cp310, cp311, cp312]
25+
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
26+
arch: [auto, aarch64]
27+
py: [cp39, cp310, cp311, cp312, cp313]
2828
exclude:
2929
- os: windows-latest
3030
arch: aarch64
31-
- os: windows-latest
32-
arch: universal2
3331
- os: macos-13
3432
arch: aarch64
35-
- os: ubuntu-latest
36-
arch: universal2
37-
# some unrelated error with installing pillow
38-
- os: ubuntu-latest
39-
py: cp38
40-
env:
41-
CIBW_BUILD: ${{ matrix.py }}-*
42-
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
33+
- os: macos-14
34+
arch: aarch64
4335
steps:
4436
- uses: actions/checkout@v4
4537
with:
4638
submodules: true
47-
fetch-depth: 0 # needed by setuptools_scm
39+
fetch-depth: 0 # needed by setuptools_scm
4840

4941
- if: ${{ matrix.arch == 'aarch64' }}
50-
uses: docker/setup-qemu-action@v2
42+
uses: docker/setup-qemu-action@v3
5143

52-
- uses: pypa/cibuildwheel@v2.16.5
44+
- uses: pypa/cibuildwheel@v2.21
5345
env:
5446
CIBW_BUILD: ${{ matrix.py }}-*
5547
CIBW_ARCHS: ${{ matrix.arch }}
5648

57-
- uses: actions/upload-artifact@v3
49+
- uses: actions/upload-artifact@v4
5850
with:
51+
name: wheel-${{ matrix.py }}-${{ matrix.os }}-${{ matrix.arch }}
5952
path: ./wheelhouse/*.whl
6053

6154
sdist:
@@ -65,28 +58,39 @@ jobs:
6558
- uses: actions/checkout@v4
6659
with:
6760
submodules: true
68-
fetch-depth: 0 # needed by setuptools_scm
61+
fetch-depth: 0 # needed by setuptools_scm
6962

7063
- uses: actions/setup-python@v4
7164
with:
72-
python-version: '3.11'
65+
python-version: "3.11"
7366

74-
- run: python -m pip install --upgrade pip setuptools wheel
75-
- run: python setup.py sdist
67+
- run: pipx run build --sdist
68+
- run: python -m pip install --upgrade pip setuptools
7669
- run: python -m pip install -v $(echo dist/*)'[test]'
7770
- run: python -m pytest
7871

79-
- uses: actions/upload-artifact@v3
72+
- uses: actions/upload-artifact@v4
8073
with:
74+
name: sdist
8175
path: dist/*.tar.gz
8276

8377
upload:
78+
if: github.event_name == 'push' && contains(github.event.ref, '/tags/')
8479
needs: [wheels, sdist]
8580
runs-on: ubuntu-latest
86-
if: github.event_name == 'push' && contains(github.event.ref, '/tags/')
81+
82+
environment:
83+
name: pypi
84+
url: https://pypi.org/project/pyhepmc/
85+
86+
permissions:
87+
id-token: write
88+
attestations: write
89+
8790
steps:
8891
- uses: actions/[email protected]
8992
with:
93+
pattern: "*"
9094
name: artifact
9195
path: dist
9296

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ var
44
build
55
dist
66
*.pyc
7+
*.pyd
78
*.so
89
*.egg-info
9-
tests/__pycache__
10+
__pycache__
1011
.eggs
1112
.cache
1213
.compiler_support_cache
@@ -17,6 +18,7 @@ py??
1718
py???
1819
.ci_bak
1920
venv
21+
.venv
2022
.coverage
2123
htmlcov
2224
src/pyhepmc/_version.py

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
repos:
1616
# Standard hooks
1717
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v4.6.0
18+
rev: v5.0.0
1919
hooks:
2020
- id: check-case-conflict
2121
- id: check-docstring-first
@@ -35,20 +35,20 @@ repos:
3535

3636
# Python formatting
3737
- repo: https://github.com/psf/black-pre-commit-mirror
38-
rev: 24.4.2
38+
rev: 24.10.0
3939
hooks:
4040
- id: black
4141

4242
# Ruff linter, replacement for flake8, pydocstyle, isort
4343
- repo: https://github.com/astral-sh/ruff-pre-commit
44-
rev: 'v0.4.5'
44+
rev: 'v0.6.9'
4545
hooks:
4646
- id: ruff
4747
args: [--fix, --show-fixes]
4848

4949
# C++ formatting
5050
- repo: https://github.com/pre-commit/mirrors-clang-format
51-
rev: v18.1.5
51+
rev: v19.1.1
5252
hooks:
5353
- id: clang-format
5454

@@ -63,7 +63,7 @@ repos:
6363

6464
# Python type checking
6565
- repo: https://github.com/pre-commit/mirrors-mypy
66-
rev: 'v1.10.0'
66+
rev: 'v1.11.2'
6767
hooks:
6868
- id: mypy
6969
# additional_dependencies: [numpy]

docs/conf.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88
import pyhepmc
9-
import os
109

1110
project = "pyhepmc"
1211
copyright = "2022, Hans Dembinski"
@@ -30,13 +29,7 @@
3029

3130
html_static_path = ["_static"]
3231

33-
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
34-
if not on_rtd:
35-
# Import and set the theme if we're building docs locally
36-
import sphinx_rtd_theme
37-
38-
html_theme = "sphinx_rtd_theme"
39-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
32+
html_theme = "sphinx_rtd_theme"
4033

4134
# Autodoc options
4235
autodoc_member_order = "groupwise"

extern/pybind11

Submodule pybind11 updated 239 files

pyproject.toml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ build-backend = "setuptools.build_meta"
1010
[project]
1111
name = "pyhepmc"
1212
description = "Pythonic interface to the HepMC3 C++ library licensed under LGPL-v3."
13-
maintainers = [
14-
{ name = "Hans Dembinski" },
15-
{ email = "[email protected]" },
16-
]
13+
maintainers = [{ name = "Hans Dembinski", email = "[email protected]" }]
1714
readme = "README.rst"
18-
requires-python = ">=3.8"
15+
requires-python = ">=3.9"
1916
license = { text = "BSD 3-Clause License" }
2017
classifiers = [
2118
"Development Status :: 5 - Production/Stable",
@@ -27,7 +24,7 @@ classifiers = [
2724
"Topic :: Scientific/Engineering",
2825
"Intended Audience :: Developers",
2926
]
30-
dependencies = ["numpy"]
27+
dependencies = ["numpy>=1.21", "packaging"]
3128
dynamic = ["version"]
3229

3330
[project.urls]
@@ -54,8 +51,9 @@ testpaths = ["tests"]
5451
log_cli_level = "INFO"
5552
xfail_strict = true
5653
filterwarnings = [
54+
"error::PendingDeprecationWarning",
5755
"error::DeprecationWarning",
58-
"error::numpy.VisibleDeprecationWarning",
56+
"error::FutureWarning",
5957
]
6058

6159
[tool.coverage.run]
@@ -66,10 +64,10 @@ source = ["pyhepmc"]
6664
exclude_lines = ["pragma: no cover"]
6765

6866
[tool.ruff]
69-
src = ["src"]
67+
exclude = ["docs/examples/*"]
7068

7169
[tool.ruff.lint]
72-
select = [
70+
extend-select = [
7371
"E",
7472
"F", # flake8
7573
"D", # pydocstyle

src/equal.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,21 @@
99
#include <HepMC3/GenParticle.h>
1010
#include <HepMC3/GenRunInfo.h>
1111
#include <HepMC3/GenVertex.h>
12+
#include <type_traits>
1213

1314
namespace HepMC3 {
1415

16+
template <class...>
17+
using void_t = void;
18+
19+
template <class, class = void>
20+
struct has_unequal_op : std::false_type {};
21+
1522
template <class T>
23+
struct has_unequal_op<T, void_t<decltype(std::declval<T>() != std::declval<T>())>>
24+
: std::true_type {};
25+
26+
template <class T, class = std::enable_if_t<!has_unequal_op<T>::value>>
1627
bool operator!=(const T& a, const T& b) {
1728
return !operator==(a, b);
1829
}

0 commit comments

Comments
 (0)