galley-jl-python 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ from typing import Any, Literal
2
+
3
+ import numpy as np
4
+
5
+ import juliacall as jc
6
+
7
+ OrderType = Literal["C", "F"] | tuple[int, ...] | None
8
+
9
+ TupleOf3Arrays = tuple[np.ndarray, np.ndarray, np.ndarray]
10
+
11
+ JuliaObj = jc.AnyValue
12
+
13
+ DType = jc.AnyValue # represents jl.DataType
14
+
15
+ spmatrix = Any
16
+
17
+ Device = Literal["cpu"] | None
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: galley-jl-python
3
+ Version: 0.1.0
4
+ Summary: Sparse Tensor Programming in Python powered by Finch.jl
5
+ License-File: LICENSE
6
+ Author: Willow Ahrens
7
+ Author-email: willow.marie.ahrens@gmail.com
8
+ Requires-Python: >=3.11,<4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
15
+ Provides-Extra: test
16
+ Requires-Dist: finch-tensor (>=0.7.0,<0.8.0)
17
+ Requires-Dist: hypothesis (>=6.151.9,<7.0.0) ; extra == "test"
18
+ Requires-Dist: juliacall (>=0.9.36,<0.9.37)
19
+ Requires-Dist: juliapkg (>=0.1.16,<0.2.0)
20
+ Requires-Dist: lark (>=1.3.0,<2.0.0)
21
+ Requires-Dist: ndindex (>=1.10.1,<2.0.0) ; extra == "test"
22
+ Requires-Dist: numba (>=0.61,<0.63.1)
23
+ Requires-Dist: numpy (>=1.19,<2.4)
24
+ Requires-Dist: pytest (>=7.4.4,<7.6) ; extra == "test"
25
+ Requires-Dist: pytest-cov (>=4.1.0,<4.2) ; extra == "test"
26
+ Requires-Dist: pytest-json-report (>=1.5.0,<2.0.0) ; extra == "test"
27
+ Requires-Dist: pytest-xdist (>=3.6.1,<4) ; extra == "test"
28
+ Requires-Dist: scipy (>=1.7,<1.17) ; extra == "test"
29
+ Requires-Dist: sparse (>=0.17.0,<0.17.1) ; extra == "test"
30
+ Description-Content-Type: text/markdown
31
+
32
+ # galley-jl-python
33
+ A sparse tensor library for Python, backed by the
34
+ [Galley.jl](https://github.com/finch-tensor/Galley.jl) framework.
35
+
36
+ ## Source
37
+
38
+ The source code for `galley-jl-python` is available on GitHub at [https://github.com/finch-tensor/galley-jl-python](https://github.com/finch-tensor/galley-jl-python).
39
+
40
+ ## Installation
41
+
42
+ `galley-jl-python` is available on PyPI, and can be installed with pip:
43
+ ```bash
44
+ pip install galley-jl-python
45
+ ```
46
+
47
+ Galley needs a Python linked against **OpenSSL 3.5 or newer**. It runs Julia
48
+ 1.12, which bundles OpenSSL 3.5 in the same process as Python. Pythons from
49
+ conda-forge, including through pixi or conda, meet this. Many system and
50
+ pyenv-built Pythons still use OpenSSL 3.0, and there `import galley_jl_python`
51
+ fails with an error that says so. Check with
52
+ `python -c "import ssl; print(ssl.OPENSSL_VERSION)"`.
53
+
54
+ ## Contributing
55
+
56
+ ### Development environment
57
+
58
+ Galley uses [pixi](https://pixi.sh) for development. All configuration lives in
59
+ `pyproject.toml`: the package metadata and dependencies are under `[project]`,
60
+ and pixi's settings are under `[tool.pixi]`.
61
+
62
+ To set up, clone the repository and run:
63
+ ```bash
64
+ pixi install # the default environment
65
+ pixi install -e test # adds the test dependencies (the `test` extra)
66
+ ```
67
+
68
+ pixi installs the package in editable mode. Julia is not a pixi dependency:
69
+ [juliapkg](https://github.com/JuliaPy/pyjuliapkg) installs the pinned Julia
70
+ version and packages the first time `galley_jl_python` is imported. To trigger
71
+ that, and to fetch the sysimage (see below), run:
72
+ ```bash
73
+ pixi run compile
74
+ ```
75
+
76
+ Run any other command inside an environment with `pixi run`, for example
77
+ `pixi run -e test python`.
78
+
79
+ The package is still built and published with Poetry (see
80
+ [Publishing](#publishing)).
81
+
82
+ ### Working with a local copy of Finch.jl
83
+ The `develop.py` script can be used to set up a local copy of Finch.jl for
84
+ development. Run it with `pixi run python develop.py`.
85
+
86
+ ```
87
+ Usage:
88
+ develop.py [--restore] [--path <path>]
89
+
90
+ Options:
91
+ --restore Restore the original juliapkg.json file.
92
+ --path Path to the local copy of Finch.jl [default: ../Finch.jl].
93
+ ```
94
+
95
+ ### Julia sysimage
96
+
97
+ Most of Galley's startup time is Julia compiling Finch itself. A prebuilt Julia
98
+ sysimage removes it: the first matmul of a session drops from about 4.5 minutes
99
+ to a few seconds.
100
+
101
+ - `import galley_jl_python` uses the image for the current platform and Julia
102
+ environment. If it isn't cached in `~/.cache/galley-jl-python/`
103
+ (`GALLEY_JL_PYTHON_CACHE` overrides this), the import downloads it from the
104
+ project's GitHub releases first, about 900 MB once per environment. It then
105
+ checks that the image loads, and if there's no image or anything fails, Julia
106
+ starts without it. Set `GALLEY_JL_PYTHON_SYSIMAGE=0` to turn all of this off.
107
+ - `pixi run fetch-sysimage` downloads the image ahead of time. `pixi run compile`
108
+ and `pixi run test` run this step first.
109
+ - `pixi run build-sysimage` builds the image locally instead, in about half an
110
+ hour.
111
+
112
+ An image works only with the exact Julia and package versions it was built
113
+ from. For this reason `src/galley_jl_python/juliapkg.json` pins Julia and every
114
+ Julia package. Each image's name includes a hash of that environment. A local
115
+ Finch.jl from `develop.py` therefore runs without the image.
116
+
117
+ To update the Julia dependencies:
118
+
119
+ 1. Loosen the pins you want to change.
120
+ 2. Resolve with `pixi run compile`.
121
+ 3. Re-pin with `python scripts/sysimage/pin_julia_deps.py`.
122
+
123
+ Pushing the new pins to `main` runs the "Sysimage" GitHub Action. It builds
124
+ images for Linux, macOS and Windows and publishes them to a `sysimage-<hash>`
125
+ GitHub release, where imports and `fetch-sysimage` find them. The action can also be run
126
+ manually from the Actions tab.
127
+
128
+ ### Publishing
129
+
130
+ The "Publish" GitHub Action is a manual workflow for publishing Python packages to PyPI using Poetry. It handles the version management based on the `pyproject.toml` file and automates tagging and creating GitHub releases.
131
+
132
+ #### Version Update
133
+
134
+ Before initiating the "Publish" action, update the package's version number in `pyproject.toml`. Follow semantic versioning guidelines for this update.
135
+
136
+ #### Triggering the Action
137
+
138
+ The action is triggered manually. Once the version in `pyproject.toml` is updated, manually start the "Publish" action from the GitHub repository's Actions tab.
139
+
140
+ #### Process and Outcomes
141
+
142
+ On successful execution, the action publishes the package to PyPI and tags the release in the GitHub repository. If the version number is not updated, the action fails to publish to PyPI, and no tagging or release is done. In case of failure, correct the version number and rerun the action.
143
+
144
+ #### Best Practices
145
+
146
+ - Ensure the version number in `pyproject.toml` is updated before triggering the action.
147
+ - Regularly check action logs for successful completion or to identify issues.
148
+
149
+ ### Pre-commit hooks
150
+
151
+ The hooks run in their own `pre-commit` environment, which doesn't install
152
+ galley's dependencies or Julia.
153
+
154
+ ```bash
155
+ pixi run pre-commit-install # run the hooks on every `git commit`
156
+ pixi run pre-commit # run every hook on every file now
157
+ pixi run pre-commit ruff # the same, skipping the listed hook ids
158
+ ```
159
+
160
+ To run a single hook, use `pixi shell -e pre-commit` and then
161
+ `pre-commit run <hook-id> -a`.
162
+
163
+ ### Testing
164
+
165
+ Galley uses [pytest](https://docs.pytest.org/en/latest/) for testing. To run the
166
+ tests:
167
+
168
+ ```bash
169
+ pixi run test # one pytest-xdist worker per CPU
170
+ pixi run test 4 # or a fixed number of workers
171
+ ```
172
+
173
+ This runs `compile` first, then two suites one after the other, each spread
174
+ over the workers:
175
+
176
+ - `pixi run test-unit` runs the unit tests.
177
+ - `pixi run test-array-api` runs the Array API tests described below.
178
+
179
+ Each worker is a separate Julia process that uses 1–2 GB of memory, so lower
180
+ the worker count on machines with little memory.
181
+
182
+ To run a subset, call pytest in the test environment directly:
183
+
184
+ ```bash
185
+ pixi run -e test pytest tests/test_fused.py
186
+ ```
187
+
188
+ Array API tests are included in `tests/test_array_api.py`. These tests invoke
189
+ the [Array API Conformance Tests](https://github.com/data-apis/array-api-tests).
190
+ To forward `pytest` options to the nested
191
+ `array-api-tests` invocation, use `--array-api` (alias:
192
+ `--array-api-pytest-args`):
193
+
194
+ ```bash
195
+ pixi run -e test pytest tests/test_array_api.py \
196
+ --array-api="-k creation_functions" \
197
+ --array-api="-x"
198
+ ```
199
+
200
+ By default, the nested Array API run forwards common top-level pytest options
201
+ from your main invocation:
202
+
203
+ - `-x`/`--maxfail`
204
+ - `-s`
205
+ - `-v`, `-vv`, etc.
206
+ - `-k`
207
+
208
+ You can repeat `--array-api` (or `--array-api-pytest-args`) multiple times.
209
+ Each value is parsed like shell arguments and appended to the nested `pytest`
210
+ call.
211
+
212
+ `ARRAY_API_TESTS_ARGS` is still supported as a fallback for compatibility, but
213
+ the CLI option is preferred.
214
+
@@ -0,0 +1,21 @@
1
+ galley_jl_python/__init__.py,sha256=E4njcWbk-Fim2EcByFtfuY0cgvd8DUT6uIATS3Wl4Tc,5058
2
+ galley_jl_python/_array_api_info.py,sha256=s-RNQxa-HqJrqLXS1MQIfW5VGKSeDZ7W3m-NRY1d1VY,2985
3
+ galley_jl_python/_sysimage.py,sha256=p1swKgq_8bWpmOmwAW5b_9_SQAXi9YAa-EHah22k7G4,7880
4
+ galley_jl_python/compiled.py,sha256=Yt9vDP0mT8pXsYXAHZgguXbtZr9Wtn5W0iC0YRcL_Mw,4784
5
+ galley_jl_python/dtypes.py,sha256=UZ9-c4qpYjw97V2y4-kcp0BnSo14DJxv4KKaHfySQJg,1423
6
+ galley_jl_python/einstein.py,sha256=5VL2NjwsjzKe9N_1BOXCoCuCsweusJWb2o-l5oDg3q8,18589
7
+ galley_jl_python/errors.py,sha256=7V_DFAPyNwFJc-KEmS51Wjn6Jf034i8OZZUkuDUeJQk,44
8
+ galley_jl_python/finch_fused.py,sha256=ehQCs3cwgM-6eVJzIbabo6e_hUvFjVPS0rW0GLvz7Vw,921
9
+ galley_jl_python/io.py,sha256=Wd7xoAB9lY2B_8cr1aZQ_Wtbp1l99NBPSRtRDtniv4w,307
10
+ galley_jl_python/julia.py,sha256=8OldIrw_YPuVaYVJ35q5Pmm20zzksnPAghCl8qJvhg8,1595
11
+ galley_jl_python/juliapkg.json,sha256=LYjDeufTj9juj7l2cANufz9sQnqfZT5_-yF0KNzSHG0,10491
12
+ galley_jl_python/juliapkg_dev.json,sha256=XkXjJr5qNZDydWdyTeBbpiMMEfa2HqZVVo0hiFufIbY,480
13
+ galley_jl_python/levels.py,sha256=vnWUxceaVPZwxjFSTmt49BQ0dlA3pGtM8McHroHcfSM,2269
14
+ galley_jl_python/linalg/__init__.py,sha256=abmVAkhC6C-_1ifk7TURxR_H5tUyMSwzHy21et6eucc,60
15
+ galley_jl_python/linalg/_linalg.py,sha256=oaXd34fKCce9F9ApiZYfeRNrQmBKtMqS9spb2tF6YXA,689
16
+ galley_jl_python/tensor.py,sha256=CF17u-Wj6ck6gfxyRrDWboqvJO7C4-6rF5uHfvmu8T8,52966
17
+ galley_jl_python/typing.py,sha256=2YMuec8u7xrR7_GsOYHHWaUzznTpruOkgEdCxFbFu8k,311
18
+ galley_jl_python-0.1.0.dist-info/METADATA,sha256=CtaOl7FaG2yadCkFAEYGzZL9BnAtnZA6ILNWK1_XsrU,8159
19
+ galley_jl_python-0.1.0.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
20
+ galley_jl_python-0.1.0.dist-info/licenses/LICENSE,sha256=LeH21ct3Ux5jK36aduuVMuEE-KME74PjVbPZdKCithM,1070
21
+ galley_jl_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.5.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Willow Ahrens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.