Skip to content

Commit bb982b5

Browse files
Fix wheels (#98)
Pulled over some updates from iminuit. Implemented workarounds for failing tests, related to matplotlib wheels which are not available on some platforms. Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a680817 commit bb982b5

File tree

8 files changed

+155
-125
lines changed

8 files changed

+155
-125
lines changed

.github/workflows/coverage.yml

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ name: Coverage
22

33
on:
44
pull_request:
5-
paths-ignore:
6-
- 'docs/**'
7-
- '*.rst'
8-
- '*.md'
5+
paths:
6+
- ".github/workflows/coverage.yml"
7+
- "**.py"
8+
- "**.cpp"
9+
- "**.hpp"
10+
- pyproject.toml
11+
- CMakeLists.txt
912
push:
1013
branches:
1114
- main
12-
paths-ignore:
13-
- 'docs/**'
14-
- '*.rst'
15-
- '*.md'
1615

1716
concurrency:
1817
group: ${{ github.workflow }}-${{ github.head_ref }}
@@ -23,25 +22,25 @@ jobs:
2322
runs-on: ubuntu-latest
2423

2524
steps:
26-
- uses: actions/checkout@v5
27-
with:
28-
submodules: true
29-
fetch-depth: 3
30-
# must come after checkout
31-
- uses: hendrikmuhs/[email protected]
32-
with:
33-
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
34-
- uses: actions/setup-python@v6
35-
with:
36-
python-version: 3.11
37-
- run: python -m pip install --upgrade pip
38-
- run: python -m pip install --prefer-binary coveralls
39-
- run: python -m pip install --prefer-binary -e .[test]
40-
- run: coverage run -m pytest
41-
- uses: ts-graphviz/setup-graphviz@v2
42-
- run: coverage run --append -m pytest
43-
- run: python -m pip uninstall --yes particle
44-
- run: coverage run --append -m pytest
45-
- run: coveralls --service=github
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- uses: actions/checkout@v5
26+
with:
27+
submodules: true
28+
fetch-depth: 3
29+
# must come after checkout
30+
- uses: hendrikmuhs/[email protected]
31+
with:
32+
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.python-version }}
33+
- uses: actions/setup-python@v6
34+
with:
35+
python-version: 3.11
36+
- run: python -m pip install --upgrade pip
37+
- run: python -m pip install --prefer-binary coveralls
38+
- run: python -m pip install --prefer-binary -e .[test]
39+
- run: coverage run -m pytest
40+
- uses: ts-graphviz/setup-graphviz@v2
41+
- run: coverage run --append -m pytest
42+
- run: python -m pip uninstall --yes particle
43+
- run: coverage run --append -m pytest
44+
- run: coveralls --service=github
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ name: Test
22

33
on:
44
pull_request:
5-
paths-ignore:
6-
- "docs/**"
7-
- "*.rst"
8-
- "*.md"
5+
paths:
6+
- ".github/workflows/test.yml"
7+
- "**.py"
8+
- "**.cpp"
9+
- "**.hpp"
10+
- pyproject.toml
11+
- CMakeLists.txt
912
workflow_dispatch:
1013

1114
concurrency:

.github/workflows/wheels.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
tags:
66
- "**"
7+
pull_request:
8+
paths:
9+
- .github/workflows/wheels.yml
10+
- pyproject.toml
711
workflow_dispatch:
812

913
concurrency:
@@ -22,29 +26,35 @@ jobs:
2226
strategy:
2327
fail-fast: false
2428
matrix:
25-
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
26-
arch: [auto, aarch64]
27-
py: [cp39, cp310, cp311, cp312, cp313]
29+
os:
30+
[
31+
ubuntu-latest,
32+
windows-latest,
33+
macos-13,
34+
macos-14,
35+
ubuntu-24.04-arm,
36+
windows-11-arm,
37+
]
38+
py: [cp39, cp310, cp311, cp312, cp313, cp314]
2839
exclude:
29-
- os: windows-latest
30-
arch: aarch64
31-
- os: macos-13
32-
arch: aarch64
33-
- os: macos-14
34-
arch: aarch64
40+
- os: ubuntu-24.04-arm
41+
py: cp39
42+
- os: windows-11-arm
43+
py: cp39
44+
- os: windows-11-arm
45+
py: cp310
46+
3547
steps:
3648
- uses: actions/checkout@v5
3749
with:
3850
submodules: true
3951
fetch-depth: 0 # needed by setuptools_scm
4052

41-
- if: ${{ matrix.arch == 'aarch64' }}
42-
uses: docker/setup-qemu-action@v3
53+
- uses: astral-sh/setup-uv@v6
4354

4455
- uses: pypa/[email protected]
4556
env:
4657
CIBW_BUILD: ${{ matrix.py }}-*
47-
CIBW_ARCHS: ${{ matrix.arch }}
4858

4959
- uses: actions/upload-artifact@v4
5060
with:
@@ -62,7 +72,7 @@ jobs:
6272

6373
- uses: actions/setup-python@v6
6474
with:
65-
python-version: "3.11"
75+
python-version: "3.12"
6676

6777
- run: pipx run build --sdist
6878
- run: python -m pip install --upgrade pip setuptools

.pre-commit-config.yaml

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,59 +13,59 @@
1313
# See https://github.com/pre-commit/pre-commit
1414

1515
repos:
16-
# Standard hooks
17-
- repo: https://github.com/pre-commit/pre-commit-hooks
18-
rev: v6.0.0
19-
hooks:
20-
- id: check-case-conflict
21-
- id: check-docstring-first
22-
- id: check-executables-have-shebangs
23-
- id: check-merge-conflict
24-
- id: check-symlinks
25-
- id: check-yaml
26-
args: ["--allow-multiple-documents"]
27-
- id: debug-statements
28-
files: src/pyhepmc/.*\\.py
29-
- id: end-of-file-fixer
30-
- id: mixed-line-ending
31-
- id: sort-simple-yaml
32-
- id: file-contents-sorter
33-
- id: trailing-whitespace
34-
exclude: ^doc/_static/.*.svg
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v6.0.0
19+
hooks:
20+
- id: check-case-conflict
21+
- id: check-docstring-first
22+
- id: check-executables-have-shebangs
23+
- id: check-merge-conflict
24+
- id: check-symlinks
25+
- id: check-yaml
26+
args: ["--allow-multiple-documents"]
27+
- id: debug-statements
28+
files: src/pyhepmc/.*\\.py
29+
- id: end-of-file-fixer
30+
- id: mixed-line-ending
31+
- id: sort-simple-yaml
32+
- id: file-contents-sorter
33+
- id: trailing-whitespace
34+
exclude: ^doc/_static/.*.svg
3535

36-
# Python formatting
37-
- repo: https://github.com/psf/black-pre-commit-mirror
38-
rev: 25.9.0
39-
hooks:
40-
- id: black
36+
# Ruff linter, replacement for flake8, pydocstyle, isort
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: "v0.14.1"
39+
hooks:
40+
- id: ruff
41+
args: [--fix, --show-fixes]
42+
- id: ruff-format
4143

42-
# Ruff linter, replacement for flake8, pydocstyle, isort
43-
- repo: https://github.com/astral-sh/ruff-pre-commit
44-
rev: 'v0.14.1'
45-
hooks:
46-
- id: ruff
47-
args: [--fix, --show-fixes]
44+
# C++ formatting
45+
- repo: https://github.com/pre-commit/mirrors-clang-format
46+
rev: v21.1.2
47+
hooks:
48+
- id: clang-format
4849

49-
# C++ formatting
50-
- repo: https://github.com/pre-commit/mirrors-clang-format
51-
rev: v21.1.2
52-
hooks:
53-
- id: clang-format
50+
# CMake formatting
51+
- repo: https://github.com/cheshirekow/cmake-format-precommit
52+
rev: v0.6.13
53+
hooks:
54+
- id: cmake-format
55+
additional_dependencies: [pyyaml]
56+
types: [file]
57+
files: (\.cmake|CMakeLists.txt)(.in)?$
5458

55-
# CMake formatting
56-
- repo: https://github.com/cheshirekow/cmake-format-precommit
57-
rev: v0.6.13
58-
hooks:
59-
- id: cmake-format
60-
additional_dependencies: [pyyaml]
61-
types: [file]
62-
files: (\.cmake|CMakeLists.txt)(.in)?$
59+
# Python type checking
60+
- repo: https://github.com/pre-commit/mirrors-mypy
61+
rev: "v1.18.2"
62+
hooks:
63+
- id: mypy
64+
# additional_dependencies: [numpy]
65+
args: [src]
66+
pass_filenames: false
6367

64-
# Python type checking
65-
- repo: https://github.com/pre-commit/mirrors-mypy
66-
rev: 'v1.18.2'
67-
hooks:
68-
- id: mypy
69-
# additional_dependencies: [numpy]
70-
args: [src]
71-
pass_filenames: false
68+
- repo: https://github.com/henryiii/validate-pyproject-schema-store
69+
rev: 2025.10.11
70+
hooks:
71+
- id: validate-pyproject

pyproject.toml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,25 @@ classifiers = [
2424
"Topic :: Scientific/Engineering",
2525
"Intended Audience :: Developers",
2626
]
27-
dependencies = ["numpy>=1.21", "packaging", "backports.zstd"]
27+
dependencies = [
28+
"numpy>=1.21",
29+
"packaging",
30+
"backports.zstd ; python_version<'3.14'",
31+
]
32+
2833
dynamic = ["version"]
2934

3035
[project.urls]
3136
repository = "https://github.com/scikit-hep/pyhepmc"
3237
documentation = "https://scikit-hep.org/pyhepmc"
3338

3439
[project.optional-dependencies]
35-
test = ["pytest", "particle", "matplotlib"]
40+
test = [
41+
"pytest",
42+
"particle",
43+
# There are issues with binary wheels on some platforms right now
44+
'matplotlib; (platform_system != "Windows" or python_version <"3.12") and (platform_system != "Linux" or platform_machine != "aarch64")',
45+
]
3646
doc = ["sphinx", "sphinx-rtd-theme", "nbsphinx", "ipython", "ipykernel"]
3747

3848
[tool.setuptools_scm]
@@ -77,6 +87,7 @@ unfixable = [
7787
]
7888
extend-ignore = [
7989
"D212", # multi-line-summary-first-line
90+
"E731", # lambda-assignment
8091
]
8192
pydocstyle.convention = "numpy"
8293

@@ -89,22 +100,18 @@ pydocstyle.convention = "numpy"
89100
"setup*.py" = ["D"]
90101

91102
[tool.cibuildwheel]
92-
# update skip when numpy wheels become available
93-
skip = ["*-musllinux_*", "cp31?-win32", "cp31?-manylinux_i686"]
103+
skip = ["cp39-musllinux_i686"] # no numpy wheel
94104
test-extras = ["test"]
95105
test-command = "python -m pytest {package}/tests"
96106
test-skip = ["*universal2:arm64"]
97-
# to match numpy, we use manylinux2014 for cp310+
98-
manylinux-x86_64-image = "manylinux2014"
99-
manylinux-i686-image = "manylinux2014"
100107

101108
[tool.cibuildwheel.environment]
102109
# this makes sure that we build only on platforms that have a corresponding numpy wheel
103110
PIP_ONLY_BINARY = ":all:"
111+
# flag is used to disable a test that doesn't work on CI
104112
CIBW = "1"
105113

106114
[[tool.cibuildwheel.overrides]]
107-
# to match numpy, we use manylinux2010 for cp36 to cp39
108-
select = "cp3?-*"
109-
manylinux-x86_64-image = "manylinux2010"
110-
manylinux-i686-image = "manylinux2010"
115+
# to match numpy, we use manylinux2014 for cp310 (and 3.9, since manylinux2010 is dead)
116+
select = "cp3{9,10}-manylinux*"
117+
manylinux-x86_64-image = "manylinux2014"

src/pyhepmc/io.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ def __init__(
222222
self,
223223
fileobj: Filename,
224224
mode: str = "r",
225-
precision: int = None,
226-
format: str = None,
225+
precision: Optional[int] = None,
226+
format: Optional[str] = None,
227227
):
228228
open_file: Optional[Callable[[], Any]] = None
229229
if hasattr(fileobj, "read") and hasattr(fileobj, "write"):
@@ -251,7 +251,9 @@ def __init__(
251251
from sys import version_info
252252

253253
if version_info >= (3, 14):
254-
from compression import zstd
254+
# The canonical import should work from 3.14 onwards,
255+
# but right now fails on Ubuntu even on 3.14
256+
from compression import zstd # pyright: ignore[reportMissingImports]
255257
else:
256258
from backports import zstd
257259
open = zstd.open
@@ -260,7 +262,7 @@ def __init__(
260262

261263
mode += "b"
262264

263-
open_file = lambda: open(fn, mode) # noqa: E731
265+
open_file = lambda: open(fn, mode)
264266

265267
self._close_file = True
266268

@@ -355,8 +357,8 @@ def close(self) -> None:
355357
def open(
356358
fileobj: Filename,
357359
mode: str = "r",
358-
precision: int = None,
359-
format: str = None,
360+
precision: Optional[int] = None,
361+
format: Optional[str] = None,
360362
) -> Any:
361363
"""
362364
Open HepMC files for reading or writing.

0 commit comments

Comments
 (0)