tangled
alpha
login
or
join now
vidyasagarv.com
/
py-oxyroot
0
fork
atom
Python bindings to oxyroot. Makes reading .root files blazing fast ๐
0
fork
atom
overview
issues
1
pulls
pipelines
maturin init
vidyasagarv.com
5 months ago
3fc98f89
+311
7 changed files
expand all
collapse all
unified
split
.github
workflows
CI.yml
.gitignore
Cargo.toml
pyproject.toml
python
py_oxyroot
__init__.py
tests
test_all.py
src
lib.rs
+181
.github/workflows/CI.yml
···
1
1
+
# This file is autogenerated by maturin v1.9.4
2
2
+
# To update, run
3
3
+
#
4
4
+
# maturin generate-ci github
5
5
+
#
6
6
+
name: CI
7
7
+
8
8
+
on:
9
9
+
push:
10
10
+
branches:
11
11
+
- main
12
12
+
- master
13
13
+
tags:
14
14
+
- '*'
15
15
+
pull_request:
16
16
+
workflow_dispatch:
17
17
+
18
18
+
permissions:
19
19
+
contents: read
20
20
+
21
21
+
jobs:
22
22
+
linux:
23
23
+
runs-on: ${{ matrix.platform.runner }}
24
24
+
strategy:
25
25
+
matrix:
26
26
+
platform:
27
27
+
- runner: ubuntu-22.04
28
28
+
target: x86_64
29
29
+
- runner: ubuntu-22.04
30
30
+
target: x86
31
31
+
- runner: ubuntu-22.04
32
32
+
target: aarch64
33
33
+
- runner: ubuntu-22.04
34
34
+
target: armv7
35
35
+
- runner: ubuntu-22.04
36
36
+
target: s390x
37
37
+
- runner: ubuntu-22.04
38
38
+
target: ppc64le
39
39
+
steps:
40
40
+
- uses: actions/checkout@v4
41
41
+
- uses: actions/setup-python@v5
42
42
+
with:
43
43
+
python-version: 3.x
44
44
+
- name: Build wheels
45
45
+
uses: PyO3/maturin-action@v1
46
46
+
with:
47
47
+
target: ${{ matrix.platform.target }}
48
48
+
args: --release --out dist --find-interpreter
49
49
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50
50
+
manylinux: auto
51
51
+
- name: Upload wheels
52
52
+
uses: actions/upload-artifact@v4
53
53
+
with:
54
54
+
name: wheels-linux-${{ matrix.platform.target }}
55
55
+
path: dist
56
56
+
57
57
+
musllinux:
58
58
+
runs-on: ${{ matrix.platform.runner }}
59
59
+
strategy:
60
60
+
matrix:
61
61
+
platform:
62
62
+
- runner: ubuntu-22.04
63
63
+
target: x86_64
64
64
+
- runner: ubuntu-22.04
65
65
+
target: x86
66
66
+
- runner: ubuntu-22.04
67
67
+
target: aarch64
68
68
+
- runner: ubuntu-22.04
69
69
+
target: armv7
70
70
+
steps:
71
71
+
- uses: actions/checkout@v4
72
72
+
- uses: actions/setup-python@v5
73
73
+
with:
74
74
+
python-version: 3.x
75
75
+
- name: Build wheels
76
76
+
uses: PyO3/maturin-action@v1
77
77
+
with:
78
78
+
target: ${{ matrix.platform.target }}
79
79
+
args: --release --out dist --find-interpreter
80
80
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81
81
+
manylinux: musllinux_1_2
82
82
+
- name: Upload wheels
83
83
+
uses: actions/upload-artifact@v4
84
84
+
with:
85
85
+
name: wheels-musllinux-${{ matrix.platform.target }}
86
86
+
path: dist
87
87
+
88
88
+
windows:
89
89
+
runs-on: ${{ matrix.platform.runner }}
90
90
+
strategy:
91
91
+
matrix:
92
92
+
platform:
93
93
+
- runner: windows-latest
94
94
+
target: x64
95
95
+
- runner: windows-latest
96
96
+
target: x86
97
97
+
steps:
98
98
+
- uses: actions/checkout@v4
99
99
+
- uses: actions/setup-python@v5
100
100
+
with:
101
101
+
python-version: 3.x
102
102
+
architecture: ${{ matrix.platform.target }}
103
103
+
- name: Build wheels
104
104
+
uses: PyO3/maturin-action@v1
105
105
+
with:
106
106
+
target: ${{ matrix.platform.target }}
107
107
+
args: --release --out dist --find-interpreter
108
108
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
109
109
+
- name: Upload wheels
110
110
+
uses: actions/upload-artifact@v4
111
111
+
with:
112
112
+
name: wheels-windows-${{ matrix.platform.target }}
113
113
+
path: dist
114
114
+
115
115
+
macos:
116
116
+
runs-on: ${{ matrix.platform.runner }}
117
117
+
strategy:
118
118
+
matrix:
119
119
+
platform:
120
120
+
- runner: macos-13
121
121
+
target: x86_64
122
122
+
- runner: macos-14
123
123
+
target: aarch64
124
124
+
steps:
125
125
+
- uses: actions/checkout@v4
126
126
+
- uses: actions/setup-python@v5
127
127
+
with:
128
128
+
python-version: 3.x
129
129
+
- name: Build wheels
130
130
+
uses: PyO3/maturin-action@v1
131
131
+
with:
132
132
+
target: ${{ matrix.platform.target }}
133
133
+
args: --release --out dist --find-interpreter
134
134
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
135
135
+
- name: Upload wheels
136
136
+
uses: actions/upload-artifact@v4
137
137
+
with:
138
138
+
name: wheels-macos-${{ matrix.platform.target }}
139
139
+
path: dist
140
140
+
141
141
+
sdist:
142
142
+
runs-on: ubuntu-latest
143
143
+
steps:
144
144
+
- uses: actions/checkout@v4
145
145
+
- name: Build sdist
146
146
+
uses: PyO3/maturin-action@v1
147
147
+
with:
148
148
+
command: sdist
149
149
+
args: --out dist
150
150
+
- name: Upload sdist
151
151
+
uses: actions/upload-artifact@v4
152
152
+
with:
153
153
+
name: wheels-sdist
154
154
+
path: dist
155
155
+
156
156
+
release:
157
157
+
name: Release
158
158
+
runs-on: ubuntu-latest
159
159
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160
160
+
needs: [linux, musllinux, windows, macos, sdist]
161
161
+
permissions:
162
162
+
# Use to sign the release artifacts
163
163
+
id-token: write
164
164
+
# Used to upload release artifacts
165
165
+
contents: write
166
166
+
# Used to generate artifact attestation
167
167
+
attestations: write
168
168
+
steps:
169
169
+
- uses: actions/download-artifact@v4
170
170
+
- name: Generate artifact attestation
171
171
+
uses: actions/attest-build-provenance@v2
172
172
+
with:
173
173
+
subject-path: 'wheels-*/*'
174
174
+
- name: Publish to PyPI
175
175
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
176
176
+
uses: PyO3/maturin-action@v1
177
177
+
env:
178
178
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
179
179
+
with:
180
180
+
command: upload
181
181
+
args: --non-interactive --skip-existing wheels-*/*
+72
.gitignore
···
1
1
+
/target
2
2
+
3
3
+
# Byte-compiled / optimized / DLL files
4
4
+
__pycache__/
5
5
+
.pytest_cache/
6
6
+
*.py[cod]
7
7
+
8
8
+
# C extensions
9
9
+
*.so
10
10
+
11
11
+
# Distribution / packaging
12
12
+
.Python
13
13
+
.venv/
14
14
+
env/
15
15
+
bin/
16
16
+
build/
17
17
+
develop-eggs/
18
18
+
dist/
19
19
+
eggs/
20
20
+
lib/
21
21
+
lib64/
22
22
+
parts/
23
23
+
sdist/
24
24
+
var/
25
25
+
include/
26
26
+
man/
27
27
+
venv/
28
28
+
*.egg-info/
29
29
+
.installed.cfg
30
30
+
*.egg
31
31
+
32
32
+
# Installer logs
33
33
+
pip-log.txt
34
34
+
pip-delete-this-directory.txt
35
35
+
pip-selfcheck.json
36
36
+
37
37
+
# Unit test / coverage reports
38
38
+
htmlcov/
39
39
+
.tox/
40
40
+
.coverage
41
41
+
.cache
42
42
+
nosetests.xml
43
43
+
coverage.xml
44
44
+
45
45
+
# Translations
46
46
+
*.mo
47
47
+
48
48
+
# Mr Developer
49
49
+
.mr.developer.cfg
50
50
+
.project
51
51
+
.pydevproject
52
52
+
53
53
+
# Rope
54
54
+
.ropeproject
55
55
+
56
56
+
# Django stuff:
57
57
+
*.log
58
58
+
*.pot
59
59
+
60
60
+
.DS_Store
61
61
+
62
62
+
# Sphinx documentation
63
63
+
docs/_build/
64
64
+
65
65
+
# PyCharm
66
66
+
.idea/
67
67
+
68
68
+
# VSCode
69
69
+
.vscode/
70
70
+
71
71
+
# Pyenv
72
72
+
.python-version
+12
Cargo.toml
···
1
1
+
[package]
2
2
+
name = "py-oxyroot"
3
3
+
version = "0.1.0"
4
4
+
edition = "2021"
5
5
+
6
6
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
7
+
[lib]
8
8
+
name = "py_oxyroot"
9
9
+
crate-type = ["cdylib"]
10
10
+
11
11
+
[dependencies]
12
12
+
pyo3 = "0.25.0"
+20
pyproject.toml
···
1
1
+
[build-system]
2
2
+
requires = ["maturin>=1.9,<2.0"]
3
3
+
build-backend = "maturin"
4
4
+
5
5
+
[project]
6
6
+
name = "py-oxyroot"
7
7
+
requires-python = ">=3.8"
8
8
+
classifiers = [
9
9
+
"Programming Language :: Rust",
10
10
+
"Programming Language :: Python :: Implementation :: CPython",
11
11
+
"Programming Language :: Python :: Implementation :: PyPy",
12
12
+
]
13
13
+
dynamic = ["version"]
14
14
+
[project.optional-dependencies]
15
15
+
tests = [
16
16
+
"pytest",
17
17
+
]
18
18
+
[tool.maturin]
19
19
+
python-source = "python"
20
20
+
features = ["pyo3/extension-module"]
+6
python/py_oxyroot/__init__.py
···
1
1
+
from .py_oxyroot import *
2
2
+
3
3
+
4
4
+
__doc__ = py_oxyroot.__doc__
5
5
+
if hasattr(py_oxyroot, "__all__"):
6
6
+
__all__ = py_oxyroot.__all__
+6
python/tests/test_all.py
···
1
1
+
import pytest
2
2
+
import py_oxyroot
3
3
+
4
4
+
5
5
+
def test_sum_as_string():
6
6
+
assert py_oxyroot.sum_as_string(1, 1) == "2"
+14
src/lib.rs
···
1
1
+
use pyo3::prelude::*;
2
2
+
3
3
+
/// Formats the sum of two numbers as string.
4
4
+
#[pyfunction]
5
5
+
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
6
6
+
Ok((a + b).to_string())
7
7
+
}
8
8
+
9
9
+
/// A Python module implemented in Rust.
10
10
+
#[pymodule]
11
11
+
fn py_oxyroot(m: &Bound<'_, PyModule>) -> PyResult<()> {
12
12
+
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
13
13
+
Ok(())
14
14
+
}