sizestr 1.0.0__tar.gz
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.
- sizestr-1.0.0/.envrc +3 -0
- sizestr-1.0.0/.gitattributes +2 -0
- sizestr-1.0.0/.github/workflows/workflow.yaml +230 -0
- sizestr-1.0.0/.gitignore +219 -0
- sizestr-1.0.0/.vscode/settings.json +7 -0
- sizestr-1.0.0/Cargo.lock +171 -0
- sizestr-1.0.0/Cargo.toml +14 -0
- sizestr-1.0.0/LICENSE +24 -0
- sizestr-1.0.0/PKG-INFO +53 -0
- sizestr-1.0.0/README.md +25 -0
- sizestr-1.0.0/pyproject.toml +160 -0
- sizestr-1.0.0/python/sizestr/__init__.py +5 -0
- sizestr-1.0.0/python/sizestr/_lib.pyi +9 -0
- sizestr-1.0.0/python/sizestr/py.typed +0 -0
- sizestr-1.0.0/shell.nix +52 -0
- sizestr-1.0.0/src/lib.rs +39 -0
- sizestr-1.0.0/tests/test___init__.py +25 -0
- sizestr-1.0.0/uv.lock +88 -0
sizestr-1.0.0/.envrc
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# This file is autogenerated by maturin v1.7.0
|
|
2
|
+
# To update, run
|
|
3
|
+
#
|
|
4
|
+
# maturin generate-ci github --platform all --zig
|
|
5
|
+
#
|
|
6
|
+
name: CI
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
tags:
|
|
13
|
+
- "*"
|
|
14
|
+
pull_request:
|
|
15
|
+
branches:
|
|
16
|
+
- main
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
test:
|
|
23
|
+
name: Run tests
|
|
24
|
+
runs-on: ${{ matrix.runner }}
|
|
25
|
+
strategy:
|
|
26
|
+
matrix:
|
|
27
|
+
runner:
|
|
28
|
+
- ubuntu-latest
|
|
29
|
+
- macos-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
33
|
+
- uses: cachix/install-nix-action@v27
|
|
34
|
+
with:
|
|
35
|
+
nix_path: nixpkgs=channel:nixpkgs-24.05-darwin
|
|
36
|
+
|
|
37
|
+
- name: Generate cache key
|
|
38
|
+
run: |
|
|
39
|
+
nixpkgs_hash=$(egrep -o 'archive/[0-9a-f]{40}\.tar\.gz' shell.nix | cut -d'/' -f2 | cut -d'.' -f1)
|
|
40
|
+
echo "CACHE_KEY=${{ runner.os }}-$nixpkgs_hash" >> $GITHUB_ENV
|
|
41
|
+
|
|
42
|
+
- name: Cache Nix store
|
|
43
|
+
uses: actions/cache@v4
|
|
44
|
+
id: nix-cache
|
|
45
|
+
with:
|
|
46
|
+
key: nix-${{ env.CACHE_KEY }}
|
|
47
|
+
path: /tmp/nix-cache
|
|
48
|
+
|
|
49
|
+
- name: Import Nix store cache
|
|
50
|
+
if: steps.nix-cache.outputs.cache-hit == 'true'
|
|
51
|
+
run: |
|
|
52
|
+
nix-store --import < /tmp/nix-cache
|
|
53
|
+
|
|
54
|
+
- name: Cache Python packages
|
|
55
|
+
uses: actions/cache@v4
|
|
56
|
+
with:
|
|
57
|
+
key: python-${{ env.CACHE_KEY }}-${{ hashFiles('uv.lock') }}
|
|
58
|
+
path: ~/.cache/uv
|
|
59
|
+
|
|
60
|
+
- name: Install dependencies
|
|
61
|
+
run: |
|
|
62
|
+
nix-shell --run true
|
|
63
|
+
|
|
64
|
+
- name: Export Nix store cache
|
|
65
|
+
if: steps.nix-cache.outputs.cache-hit != 'true'
|
|
66
|
+
run: |
|
|
67
|
+
nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nix-cache
|
|
68
|
+
|
|
69
|
+
- name: Assert tag name matches version
|
|
70
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
|
71
|
+
run: |
|
|
72
|
+
nix-shell --pure --run "uv tree 2>&1 | grep -o 'sizestr v.*' | sed 's/sizestr v//' > version.txt"
|
|
73
|
+
version=$(cat version.txt)
|
|
74
|
+
tag_name=${{ github.ref_name }}
|
|
75
|
+
if [ "$version" != "$tag_name" ]; then
|
|
76
|
+
echo "Tag name mismatch: $version != $tag_name"
|
|
77
|
+
exit 1
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
- name: Run tests
|
|
81
|
+
run: |
|
|
82
|
+
nix-shell --pure --run run-tests
|
|
83
|
+
|
|
84
|
+
linux:
|
|
85
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
86
|
+
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
|
|
87
|
+
needs: test
|
|
88
|
+
strategy:
|
|
89
|
+
matrix:
|
|
90
|
+
platform:
|
|
91
|
+
- runner: ubuntu-latest
|
|
92
|
+
target: x86_64
|
|
93
|
+
- runner: ubuntu-latest
|
|
94
|
+
target: aarch64
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/checkout@v4
|
|
97
|
+
- uses: actions/setup-python@v5
|
|
98
|
+
with:
|
|
99
|
+
python-version: 3.x
|
|
100
|
+
- name: Build wheels
|
|
101
|
+
uses: PyO3/maturin-action@v1
|
|
102
|
+
with:
|
|
103
|
+
target: ${{ matrix.platform.target }}
|
|
104
|
+
args: --release --out dist --zig
|
|
105
|
+
sccache: "true"
|
|
106
|
+
manylinux: auto
|
|
107
|
+
- name: Upload wheels
|
|
108
|
+
uses: actions/upload-artifact@v4
|
|
109
|
+
with:
|
|
110
|
+
name: wheels-linux-${{ matrix.platform.target }}
|
|
111
|
+
path: dist
|
|
112
|
+
|
|
113
|
+
musllinux:
|
|
114
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
115
|
+
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
|
|
116
|
+
needs: test
|
|
117
|
+
strategy:
|
|
118
|
+
matrix:
|
|
119
|
+
platform:
|
|
120
|
+
- runner: ubuntu-latest
|
|
121
|
+
target: x86_64
|
|
122
|
+
- runner: ubuntu-latest
|
|
123
|
+
target: aarch64
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: 3.x
|
|
129
|
+
- name: Build wheels
|
|
130
|
+
uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
target: ${{ matrix.platform.target }}
|
|
133
|
+
args: --release --out dist
|
|
134
|
+
sccache: "true"
|
|
135
|
+
manylinux: musllinux_1_2
|
|
136
|
+
- name: Upload wheels
|
|
137
|
+
uses: actions/upload-artifact@v4
|
|
138
|
+
with:
|
|
139
|
+
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
140
|
+
path: dist
|
|
141
|
+
|
|
142
|
+
windows:
|
|
143
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
144
|
+
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
|
|
145
|
+
needs: test
|
|
146
|
+
strategy:
|
|
147
|
+
matrix:
|
|
148
|
+
platform:
|
|
149
|
+
- runner: windows-latest
|
|
150
|
+
target: x64
|
|
151
|
+
steps:
|
|
152
|
+
- uses: actions/checkout@v4
|
|
153
|
+
- uses: actions/setup-python@v5
|
|
154
|
+
with:
|
|
155
|
+
python-version: 3.x
|
|
156
|
+
architecture: ${{ matrix.platform.target }}
|
|
157
|
+
- name: Build wheels
|
|
158
|
+
uses: PyO3/maturin-action@v1
|
|
159
|
+
with:
|
|
160
|
+
target: ${{ matrix.platform.target }}
|
|
161
|
+
args: --release --out dist
|
|
162
|
+
sccache: "true"
|
|
163
|
+
- name: Upload wheels
|
|
164
|
+
uses: actions/upload-artifact@v4
|
|
165
|
+
with:
|
|
166
|
+
name: wheels-windows-${{ matrix.platform.target }}
|
|
167
|
+
path: dist
|
|
168
|
+
|
|
169
|
+
macos:
|
|
170
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
171
|
+
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
|
|
172
|
+
needs: test
|
|
173
|
+
strategy:
|
|
174
|
+
matrix:
|
|
175
|
+
platform:
|
|
176
|
+
- runner: macos-12
|
|
177
|
+
target: x86_64
|
|
178
|
+
- runner: macos-14
|
|
179
|
+
target: aarch64
|
|
180
|
+
steps:
|
|
181
|
+
- uses: actions/checkout@v4
|
|
182
|
+
- uses: actions/setup-python@v5
|
|
183
|
+
with:
|
|
184
|
+
python-version: 3.x
|
|
185
|
+
- name: Build wheels
|
|
186
|
+
uses: PyO3/maturin-action@v1
|
|
187
|
+
with:
|
|
188
|
+
target: ${{ matrix.platform.target }}
|
|
189
|
+
args: --release --out dist
|
|
190
|
+
sccache: "true"
|
|
191
|
+
- name: Upload wheels
|
|
192
|
+
uses: actions/upload-artifact@v4
|
|
193
|
+
with:
|
|
194
|
+
name: wheels-macos-${{ matrix.platform.target }}
|
|
195
|
+
path: dist
|
|
196
|
+
|
|
197
|
+
sdist:
|
|
198
|
+
runs-on: ubuntu-latest
|
|
199
|
+
needs: test
|
|
200
|
+
steps:
|
|
201
|
+
- uses: actions/checkout@v4
|
|
202
|
+
- name: Build sdist
|
|
203
|
+
uses: PyO3/maturin-action@v1
|
|
204
|
+
with:
|
|
205
|
+
command: sdist
|
|
206
|
+
args: --out dist
|
|
207
|
+
- name: Upload sdist
|
|
208
|
+
uses: actions/upload-artifact@v4
|
|
209
|
+
with:
|
|
210
|
+
name: wheels-sdist
|
|
211
|
+
path: dist
|
|
212
|
+
|
|
213
|
+
release:
|
|
214
|
+
name: Release
|
|
215
|
+
runs-on: ubuntu-latest
|
|
216
|
+
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
|
|
217
|
+
needs: [linux, musllinux, windows, macos, sdist]
|
|
218
|
+
environment:
|
|
219
|
+
name: pypi
|
|
220
|
+
url: https://pypi.org/p/sizestr
|
|
221
|
+
permissions:
|
|
222
|
+
id-token: write
|
|
223
|
+
steps:
|
|
224
|
+
- uses: actions/download-artifact@v4
|
|
225
|
+
with:
|
|
226
|
+
pattern: wheels-*
|
|
227
|
+
path: dist
|
|
228
|
+
merge-multiple: true
|
|
229
|
+
- name: Publish to PyPI
|
|
230
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
sizestr-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/direnv,python,visualstudiocode,rust
|
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=direnv,python,visualstudiocode,rust
|
|
3
|
+
|
|
4
|
+
### direnv ###
|
|
5
|
+
.direnv
|
|
6
|
+
#.envrc
|
|
7
|
+
|
|
8
|
+
### Python ###
|
|
9
|
+
# Byte-compiled / optimized / DLL files
|
|
10
|
+
__pycache__/
|
|
11
|
+
*.py[cod]
|
|
12
|
+
*$py.class
|
|
13
|
+
|
|
14
|
+
# C extensions
|
|
15
|
+
*.so
|
|
16
|
+
|
|
17
|
+
# Distribution / packaging
|
|
18
|
+
.Python
|
|
19
|
+
build/
|
|
20
|
+
develop-eggs/
|
|
21
|
+
dist/
|
|
22
|
+
downloads/
|
|
23
|
+
eggs/
|
|
24
|
+
.eggs/
|
|
25
|
+
lib/
|
|
26
|
+
lib64/
|
|
27
|
+
parts/
|
|
28
|
+
sdist/
|
|
29
|
+
var/
|
|
30
|
+
wheels/
|
|
31
|
+
share/python-wheels/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
MANIFEST
|
|
36
|
+
|
|
37
|
+
# PyInstaller
|
|
38
|
+
# Usually these files are written by a python script from a template
|
|
39
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
40
|
+
*.manifest
|
|
41
|
+
*.spec
|
|
42
|
+
|
|
43
|
+
# Installer logs
|
|
44
|
+
pip-log.txt
|
|
45
|
+
pip-delete-this-directory.txt
|
|
46
|
+
|
|
47
|
+
# Unit test / coverage reports
|
|
48
|
+
htmlcov/
|
|
49
|
+
.tox/
|
|
50
|
+
.nox/
|
|
51
|
+
.coverage
|
|
52
|
+
.coverage.*
|
|
53
|
+
.cache
|
|
54
|
+
nosetests.xml
|
|
55
|
+
coverage.xml
|
|
56
|
+
*.cover
|
|
57
|
+
*.py,cover
|
|
58
|
+
.hypothesis/
|
|
59
|
+
.pytest_cache/
|
|
60
|
+
cover/
|
|
61
|
+
|
|
62
|
+
# Translations
|
|
63
|
+
*.mo
|
|
64
|
+
*.pot
|
|
65
|
+
|
|
66
|
+
# Django stuff:
|
|
67
|
+
*.log
|
|
68
|
+
local_settings.py
|
|
69
|
+
db.sqlite3
|
|
70
|
+
db.sqlite3-journal
|
|
71
|
+
|
|
72
|
+
# Flask stuff:
|
|
73
|
+
instance/
|
|
74
|
+
.webassets-cache
|
|
75
|
+
|
|
76
|
+
# Scrapy stuff:
|
|
77
|
+
.scrapy
|
|
78
|
+
|
|
79
|
+
# Sphinx documentation
|
|
80
|
+
docs/_build/
|
|
81
|
+
|
|
82
|
+
# PyBuilder
|
|
83
|
+
.pybuilder/
|
|
84
|
+
target/
|
|
85
|
+
|
|
86
|
+
# Jupyter Notebook
|
|
87
|
+
.ipynb_checkpoints
|
|
88
|
+
|
|
89
|
+
# IPython
|
|
90
|
+
profile_default/
|
|
91
|
+
ipython_config.py
|
|
92
|
+
|
|
93
|
+
# pyenv
|
|
94
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
95
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
96
|
+
# .python-version
|
|
97
|
+
|
|
98
|
+
# pipenv
|
|
99
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
100
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
101
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
102
|
+
# install all needed dependencies.
|
|
103
|
+
#Pipfile.lock
|
|
104
|
+
|
|
105
|
+
# poetry
|
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
107
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
108
|
+
# commonly ignored for libraries.
|
|
109
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
110
|
+
#poetry.lock
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
#pdm.lock
|
|
115
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
116
|
+
# in version control.
|
|
117
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
118
|
+
.pdm.toml
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
### Python Patch ###
|
|
171
|
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
|
172
|
+
#poetry.toml
|
|
173
|
+
|
|
174
|
+
# ruff
|
|
175
|
+
.ruff_cache/
|
|
176
|
+
|
|
177
|
+
# LSP config files
|
|
178
|
+
pyrightconfig.json
|
|
179
|
+
|
|
180
|
+
### Rust ###
|
|
181
|
+
# Generated by Cargo
|
|
182
|
+
# will have compiled files and executables
|
|
183
|
+
debug/
|
|
184
|
+
|
|
185
|
+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
|
186
|
+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
|
187
|
+
Cargo.lock
|
|
188
|
+
|
|
189
|
+
# These are backup files generated by rustfmt
|
|
190
|
+
**/*.rs.bk
|
|
191
|
+
|
|
192
|
+
# MSVC Windows builds of rustc generate these, which store debugging information
|
|
193
|
+
*.pdb
|
|
194
|
+
|
|
195
|
+
### VisualStudioCode ###
|
|
196
|
+
.vscode/*
|
|
197
|
+
!.vscode/settings.json
|
|
198
|
+
!.vscode/tasks.json
|
|
199
|
+
!.vscode/launch.json
|
|
200
|
+
!.vscode/extensions.json
|
|
201
|
+
!.vscode/*.code-snippets
|
|
202
|
+
|
|
203
|
+
# Local History for Visual Studio Code
|
|
204
|
+
.history/
|
|
205
|
+
|
|
206
|
+
# Built Visual Studio Code Extensions
|
|
207
|
+
*.vsix
|
|
208
|
+
|
|
209
|
+
### VisualStudioCode Patch ###
|
|
210
|
+
# Ignore all local history of files
|
|
211
|
+
.history
|
|
212
|
+
.ionide
|
|
213
|
+
|
|
214
|
+
# End of https://www.toptal.com/developers/gitignore/api/direnv,python,visualstudiocode,rust
|
|
215
|
+
|
|
216
|
+
# Python version lock
|
|
217
|
+
.python-version
|
|
218
|
+
|
|
219
|
+
.intentionally-empty-file.*
|
sizestr-1.0.0/Cargo.lock
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.3.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cfg-if"
|
|
13
|
+
version = "1.0.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "heck"
|
|
19
|
+
version = "0.5.0"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "indoc"
|
|
25
|
+
version = "2.0.5"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "libc"
|
|
31
|
+
version = "0.2.158"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
|
34
|
+
|
|
35
|
+
[[package]]
|
|
36
|
+
name = "memoffset"
|
|
37
|
+
version = "0.9.1"
|
|
38
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
40
|
+
dependencies = [
|
|
41
|
+
"autocfg",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
[[package]]
|
|
45
|
+
name = "once_cell"
|
|
46
|
+
version = "1.20.0"
|
|
47
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
48
|
+
checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe"
|
|
49
|
+
|
|
50
|
+
[[package]]
|
|
51
|
+
name = "portable-atomic"
|
|
52
|
+
version = "1.7.0"
|
|
53
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
+
checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265"
|
|
55
|
+
|
|
56
|
+
[[package]]
|
|
57
|
+
name = "proc-macro2"
|
|
58
|
+
version = "1.0.86"
|
|
59
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
60
|
+
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
|
|
61
|
+
dependencies = [
|
|
62
|
+
"unicode-ident",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "pyo3"
|
|
67
|
+
version = "0.22.2"
|
|
68
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
69
|
+
checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433"
|
|
70
|
+
dependencies = [
|
|
71
|
+
"cfg-if",
|
|
72
|
+
"indoc",
|
|
73
|
+
"libc",
|
|
74
|
+
"memoffset",
|
|
75
|
+
"once_cell",
|
|
76
|
+
"portable-atomic",
|
|
77
|
+
"pyo3-build-config",
|
|
78
|
+
"pyo3-ffi",
|
|
79
|
+
"pyo3-macros",
|
|
80
|
+
"unindent",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[[package]]
|
|
84
|
+
name = "pyo3-build-config"
|
|
85
|
+
version = "0.22.2"
|
|
86
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
87
|
+
checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8"
|
|
88
|
+
dependencies = [
|
|
89
|
+
"once_cell",
|
|
90
|
+
"target-lexicon",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[[package]]
|
|
94
|
+
name = "pyo3-ffi"
|
|
95
|
+
version = "0.22.2"
|
|
96
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
97
|
+
checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6"
|
|
98
|
+
dependencies = [
|
|
99
|
+
"libc",
|
|
100
|
+
"pyo3-build-config",
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
[[package]]
|
|
104
|
+
name = "pyo3-macros"
|
|
105
|
+
version = "0.22.2"
|
|
106
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
107
|
+
checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206"
|
|
108
|
+
dependencies = [
|
|
109
|
+
"proc-macro2",
|
|
110
|
+
"pyo3-macros-backend",
|
|
111
|
+
"quote",
|
|
112
|
+
"syn",
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
[[package]]
|
|
116
|
+
name = "pyo3-macros-backend"
|
|
117
|
+
version = "0.22.2"
|
|
118
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
119
|
+
checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372"
|
|
120
|
+
dependencies = [
|
|
121
|
+
"heck",
|
|
122
|
+
"proc-macro2",
|
|
123
|
+
"pyo3-build-config",
|
|
124
|
+
"quote",
|
|
125
|
+
"syn",
|
|
126
|
+
]
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "quote"
|
|
130
|
+
version = "1.0.37"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
|
133
|
+
dependencies = [
|
|
134
|
+
"proc-macro2",
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
[[package]]
|
|
138
|
+
name = "sizestr"
|
|
139
|
+
version = "1.0.0"
|
|
140
|
+
dependencies = [
|
|
141
|
+
"pyo3",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
[[package]]
|
|
145
|
+
name = "syn"
|
|
146
|
+
version = "2.0.77"
|
|
147
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
148
|
+
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
|
149
|
+
dependencies = [
|
|
150
|
+
"proc-macro2",
|
|
151
|
+
"quote",
|
|
152
|
+
"unicode-ident",
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
[[package]]
|
|
156
|
+
name = "target-lexicon"
|
|
157
|
+
version = "0.12.16"
|
|
158
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
159
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
160
|
+
|
|
161
|
+
[[package]]
|
|
162
|
+
name = "unicode-ident"
|
|
163
|
+
version = "1.0.13"
|
|
164
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
165
|
+
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
|
166
|
+
|
|
167
|
+
[[package]]
|
|
168
|
+
name = "unindent"
|
|
169
|
+
version = "0.2.3"
|
|
170
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
171
|
+
checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
|
sizestr-1.0.0/Cargo.toml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
edition = "2021"
|
|
3
|
+
name = "sizestr"
|
|
4
|
+
version = "1.0.0"
|
|
5
|
+
|
|
6
|
+
[lib]
|
|
7
|
+
crate-type = ["cdylib"]
|
|
8
|
+
name = "sizestr"
|
|
9
|
+
|
|
10
|
+
[dependencies]
|
|
11
|
+
pyo3 = {version = "0.22.2", features = ["extension-module", "abi3-py38"]}
|
|
12
|
+
|
|
13
|
+
[profile.release]
|
|
14
|
+
overflow-checks = true
|
sizestr-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <https://unlicense.org>
|
sizestr-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: sizestr
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
5
|
+
Classifier: Intended Audience :: Developers
|
|
6
|
+
Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
15
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
16
|
+
Classifier: Programming Language :: Rust
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Summary: Simple and fast formatting of sizes for Python
|
|
21
|
+
Keywords: lrucache,lru,cache,caching
|
|
22
|
+
Author-email: Kamil Monicz <kamil@monicz.dev>
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
25
|
+
Project-URL: Issues, https://github.com/Zaczero/sizestr/issues
|
|
26
|
+
Project-URL: Repository, https://github.com/Zaczero/sizestr
|
|
27
|
+
|
|
28
|
+
# sizestr
|
|
29
|
+
|
|
30
|
+
[](https://pypi.org/project/sizestr)
|
|
31
|
+
[](https://liberapay.com/Zaczero/)
|
|
32
|
+
[](https://github.com/sponsors/Zaczero)
|
|
33
|
+
|
|
34
|
+
Simple and fast formatting of sizes for Python.
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
The recommended installation method is through the PyPI package manager. The project is implemented in Rust and several pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pip install sizestr
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Basic usage
|
|
45
|
+
|
|
46
|
+
```py
|
|
47
|
+
from sizestr import sizestr
|
|
48
|
+
|
|
49
|
+
sizestr(10000) # '9.77 KiB'
|
|
50
|
+
sizestr(-42) # '-42 B'
|
|
51
|
+
sizestr(float('inf')) # '(inf)'
|
|
52
|
+
```
|
|
53
|
+
|
sizestr-1.0.0/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# sizestr
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/sizestr)
|
|
4
|
+
[](https://liberapay.com/Zaczero/)
|
|
5
|
+
[](https://github.com/sponsors/Zaczero)
|
|
6
|
+
|
|
7
|
+
Simple and fast formatting of sizes for Python.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
The recommended installation method is through the PyPI package manager. The project is implemented in Rust and several pre-built binary wheels are available for Linux, macOS, and Windows, with support for both x64 and ARM architectures.
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pip install sizestr
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Basic usage
|
|
18
|
+
|
|
19
|
+
```py
|
|
20
|
+
from sizestr import sizestr
|
|
21
|
+
|
|
22
|
+
sizestr(10000) # '9.77 KiB'
|
|
23
|
+
sizestr(-42) # '-42 B'
|
|
24
|
+
sizestr(float('inf')) # '(inf)'
|
|
25
|
+
```
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
authors = [{name = "Kamil Monicz", email = "kamil@monicz.dev"}]
|
|
3
|
+
classifiers = [
|
|
4
|
+
"Development Status :: 5 - Production/Stable",
|
|
5
|
+
"Intended Audience :: Developers",
|
|
6
|
+
"License :: OSI Approved :: The Unlicense (Unlicense)",
|
|
7
|
+
"Operating System :: OS Independent",
|
|
8
|
+
"Programming Language :: Python :: 3.8",
|
|
9
|
+
"Programming Language :: Python :: 3.9",
|
|
10
|
+
"Programming Language :: Python :: 3.10",
|
|
11
|
+
"Programming Language :: Python :: 3.11",
|
|
12
|
+
"Programming Language :: Python :: 3.12",
|
|
13
|
+
"Programming Language :: Python :: 3.13",
|
|
14
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
15
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
16
|
+
"Programming Language :: Rust",
|
|
17
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
18
|
+
"Typing :: Typed",
|
|
19
|
+
]
|
|
20
|
+
dependencies = []
|
|
21
|
+
description = "Simple and fast formatting of sizes for Python"
|
|
22
|
+
dynamic = ["version"]
|
|
23
|
+
keywords = ["lrucache", "lru", "cache", "caching"]
|
|
24
|
+
name = "sizestr"
|
|
25
|
+
readme = "README.md"
|
|
26
|
+
requires-python = ">=3.8"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Issues = "https://github.com/Zaczero/sizestr/issues"
|
|
30
|
+
Repository = "https://github.com/Zaczero/sizestr"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
build-backend = "maturin"
|
|
34
|
+
requires = ["maturin>=1.7,<2.0"]
|
|
35
|
+
|
|
36
|
+
[tool.maturin]
|
|
37
|
+
features = ["pyo3/extension-module"]
|
|
38
|
+
module-name = "sizestr._lib"
|
|
39
|
+
python-source = "python"
|
|
40
|
+
|
|
41
|
+
[tool.uv]
|
|
42
|
+
dev-dependencies = [
|
|
43
|
+
"pytest",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.ruff]
|
|
47
|
+
exclude = [
|
|
48
|
+
".direnv",
|
|
49
|
+
".git",
|
|
50
|
+
".github",
|
|
51
|
+
".pytest_cache",
|
|
52
|
+
".ruff_cache",
|
|
53
|
+
".venv",
|
|
54
|
+
".vscode",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
indent-width = 4
|
|
58
|
+
line-length = 120
|
|
59
|
+
target-version = "py38"
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
# custom + https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
|
|
63
|
+
ignore = [
|
|
64
|
+
"B017", # assert-raises-exception
|
|
65
|
+
"TRY003", # raise-vanilla-args
|
|
66
|
+
"S101", # assert
|
|
67
|
+
"PT011", # pytest-raises-too-broad
|
|
68
|
+
"PYI021", # docstring-in-stub
|
|
69
|
+
"W191", # tab-indentation
|
|
70
|
+
"E111", # indentation-with-invalid-multiple
|
|
71
|
+
"E114", # indentation-with-invalid-multiple-comment
|
|
72
|
+
"E117", # over-indented
|
|
73
|
+
"E501", # line-too-long
|
|
74
|
+
"D206", # indent-with-spaces
|
|
75
|
+
"D300", # triple-single-quotes
|
|
76
|
+
"Q000", # bad-quotes-inline-string
|
|
77
|
+
"Q001", # bad-quotes-multiline-string
|
|
78
|
+
"Q002", # bad-quotes-docstring
|
|
79
|
+
"Q003", # avoidable-escaped-quote
|
|
80
|
+
"COM812", # missing-trailing-comma
|
|
81
|
+
"COM819", # prohibited-trailing-comma
|
|
82
|
+
"ISC001", # single-line-implicit-string-concatenation
|
|
83
|
+
"ISC002", # multi-line-implicit-string-concatenation
|
|
84
|
+
]
|
|
85
|
+
# see https://docs.astral.sh/ruff/rules/ for rules documentation
|
|
86
|
+
select = [
|
|
87
|
+
"A", # flake8-builtins
|
|
88
|
+
"ARG", # flake8-unused-arguments
|
|
89
|
+
"ASYNC", # flake8-async
|
|
90
|
+
"B", # flake8-bugbear
|
|
91
|
+
"C4", # flake8-comprehensions
|
|
92
|
+
"DTZ", # flake8-datetimez
|
|
93
|
+
"E4", # pycodestyle
|
|
94
|
+
"E7",
|
|
95
|
+
"E9",
|
|
96
|
+
"F", # pyflakes
|
|
97
|
+
"FA", # flake8-future-annotations
|
|
98
|
+
"FLY", # flynt # "FURB", # refurb
|
|
99
|
+
"G", # flake8-logging-format
|
|
100
|
+
"I", # isort
|
|
101
|
+
"ICN", # flake8-import-conventions
|
|
102
|
+
"INT", # flake8-gettext
|
|
103
|
+
"ISC", # flake8-implicit-str-concat
|
|
104
|
+
"LOG", # flake8-logging
|
|
105
|
+
"N", # pep8-naming
|
|
106
|
+
"NPY", # numpy
|
|
107
|
+
"Q", # flake8-quotes
|
|
108
|
+
"PERF", # perflint
|
|
109
|
+
"PIE", # flake8-pie
|
|
110
|
+
"PT", # flake8-pytest-style
|
|
111
|
+
"PTH", # flake8-use-pathlib
|
|
112
|
+
"PYI", # flake8-pyi
|
|
113
|
+
"RSE", # flake8-raise
|
|
114
|
+
"RUF", # ruff
|
|
115
|
+
"S", # flake8-bandit
|
|
116
|
+
"SIM", # flake8-simplify
|
|
117
|
+
"SLF", # flake8-self
|
|
118
|
+
"SLOT", # flake8-slots
|
|
119
|
+
"T10", # flake8-debugger
|
|
120
|
+
"TID", # flake8-tidy-imports
|
|
121
|
+
"TRY", # tryceratops
|
|
122
|
+
"UP", # pyupgrade
|
|
123
|
+
"W6",
|
|
124
|
+
"YTT", # flake8-2020
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
# allow fix for all enabled rules (when `--fix`) is provided.
|
|
128
|
+
fixable = ["ALL"]
|
|
129
|
+
unfixable = []
|
|
130
|
+
|
|
131
|
+
# allow unused variables when underscore-prefixed.
|
|
132
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
133
|
+
|
|
134
|
+
[tool.ruff.format]
|
|
135
|
+
indent-style = "space"
|
|
136
|
+
line-ending = "lf"
|
|
137
|
+
quote-style = "single"
|
|
138
|
+
skip-magic-trailing-comma = false
|
|
139
|
+
|
|
140
|
+
[tool.ruff.lint.flake8-builtins]
|
|
141
|
+
builtins-ignorelist = ["input"]
|
|
142
|
+
|
|
143
|
+
[tool.ruff.lint.flake8-quotes]
|
|
144
|
+
docstring-quotes = "double"
|
|
145
|
+
inline-quotes = "single"
|
|
146
|
+
multiline-quotes = "double"
|
|
147
|
+
|
|
148
|
+
[tool.ruff.lint.pylint]
|
|
149
|
+
max-args = 10
|
|
150
|
+
|
|
151
|
+
[tool.pyright]
|
|
152
|
+
include = ["python/sizestr", "tests"]
|
|
153
|
+
pythonPlatform = "All"
|
|
154
|
+
pythonVersion = "3.8"
|
|
155
|
+
strict = ["python/sizestr"]
|
|
156
|
+
|
|
157
|
+
[tool.pytest.ini_options]
|
|
158
|
+
addopts = "--quiet"
|
|
159
|
+
minversion = "6.0"
|
|
160
|
+
testpaths = ["tests"]
|
|
File without changes
|
sizestr-1.0.0/shell.nix
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{ isDevelopment ? true }:
|
|
2
|
+
|
|
3
|
+
let
|
|
4
|
+
# Update packages with `nixpkgs-update` command
|
|
5
|
+
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/45508c1098a3fb7140ae3d86414cee8f5ee7511c.tar.gz") { };
|
|
6
|
+
|
|
7
|
+
packages' = with pkgs; [
|
|
8
|
+
coreutils
|
|
9
|
+
python313
|
|
10
|
+
uv
|
|
11
|
+
ruff
|
|
12
|
+
maturin
|
|
13
|
+
(lib.optional stdenv.isDarwin libiconv)
|
|
14
|
+
|
|
15
|
+
(writeShellScriptBin "make" "maturin develop --uv")
|
|
16
|
+
(writeShellScriptBin "run-tests" ''
|
|
17
|
+
python -m pytest . \
|
|
18
|
+
--verbose \
|
|
19
|
+
--no-header
|
|
20
|
+
'')
|
|
21
|
+
(writeShellScriptBin "nixpkgs-update" ''
|
|
22
|
+
hash=$(
|
|
23
|
+
curl --silent --location \
|
|
24
|
+
https://prometheus.nixos.org/api/v1/query \
|
|
25
|
+
-d "query=channel_revision{channel=\"nixpkgs-unstable\"}" | \
|
|
26
|
+
grep --only-matching --extended-regexp "[0-9a-f]{40}")
|
|
27
|
+
sed -i -E "s|/nixpkgs/archive/[0-9a-f]{40}\.tar\.gz|/nixpkgs/archive/$hash.tar.gz|" shell.nix
|
|
28
|
+
echo "Nixpkgs updated to $hash"
|
|
29
|
+
'')
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
shell' = with pkgs; lib.optionalString isDevelopment ''
|
|
33
|
+
current_python=$(readlink -e .venv/bin/python || echo "")
|
|
34
|
+
current_python=''${current_python%/bin/*}
|
|
35
|
+
[ "$current_python" != "${python313}" ] && rm -rf .venv/
|
|
36
|
+
|
|
37
|
+
echo "Installing Python dependencies"
|
|
38
|
+
echo "${python313}/bin/python" > .python-version
|
|
39
|
+
NIX_ENFORCE_PURITY=0 uv sync --frozen
|
|
40
|
+
|
|
41
|
+
echo "Activating Python virtual environment"
|
|
42
|
+
source .venv/bin/activate
|
|
43
|
+
|
|
44
|
+
# Development environment variables
|
|
45
|
+
export PYTHONNOUSERSITE=1
|
|
46
|
+
export TZ=UTC
|
|
47
|
+
'';
|
|
48
|
+
in
|
|
49
|
+
pkgs.mkShell {
|
|
50
|
+
buildInputs = packages';
|
|
51
|
+
shellHook = shell';
|
|
52
|
+
}
|
sizestr-1.0.0/src/lib.rs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
use pyo3::prelude::*;
|
|
2
|
+
|
|
3
|
+
const BASE: f64 = 1024.0;
|
|
4
|
+
const SUFFIXES: [&str; 7] = [" KiB", " MiB", " GiB", " TiB", " PiB", " EiB", " ZiB"];
|
|
5
|
+
|
|
6
|
+
#[pyfunction]
|
|
7
|
+
fn sizestr(mut size: f64) -> String {
|
|
8
|
+
if !size.is_finite() {
|
|
9
|
+
return format!("({size})").to_string();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let prefix = if size.is_sign_negative() {
|
|
13
|
+
size = -size;
|
|
14
|
+
"-"
|
|
15
|
+
} else {
|
|
16
|
+
""
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if size < BASE {
|
|
20
|
+
return format!("{prefix}{size:.0} B").to_string();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for suffix in SUFFIXES {
|
|
24
|
+
size /= BASE;
|
|
25
|
+
if size < BASE {
|
|
26
|
+
let precision = if size < 10.0 { 2 } else { 1 };
|
|
27
|
+
return format!("{prefix}{size:.precision$}{suffix}").to_string();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
"(too large to display)".to_string()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#[pymodule]
|
|
35
|
+
#[pyo3(name = "_lib")]
|
|
36
|
+
fn lib(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|
37
|
+
m.add_function(wrap_pyfunction!(sizestr, m)?)?;
|
|
38
|
+
Ok(())
|
|
39
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from sizestr import sizestr
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@pytest.mark.parametrize(
|
|
6
|
+
('size', 'expected'),
|
|
7
|
+
[
|
|
8
|
+
(10000, '9.77 KiB'),
|
|
9
|
+
(1024, '1.00 KiB'),
|
|
10
|
+
(1023, '1023 B'),
|
|
11
|
+
(1, '1 B'),
|
|
12
|
+
(1e-308, '0 B'),
|
|
13
|
+
(0.0, '0 B'),
|
|
14
|
+
(0, '0 B'),
|
|
15
|
+
(-1, '-1 B'),
|
|
16
|
+
(-1023, '-1023 B'),
|
|
17
|
+
(float('inf'), '(inf)'),
|
|
18
|
+
(float('-inf'), '(-inf)'),
|
|
19
|
+
(float('NaN'), '(NaN)'),
|
|
20
|
+
(1e24, '847.0 ZiB'),
|
|
21
|
+
(1e25, '(too large to display)'),
|
|
22
|
+
],
|
|
23
|
+
)
|
|
24
|
+
def test_sizestr(size, expected):
|
|
25
|
+
assert sizestr(size) == expected
|
sizestr-1.0.0/uv.lock
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
version = 1
|
|
2
|
+
requires-python = ">=3.8"
|
|
3
|
+
|
|
4
|
+
[[package]]
|
|
5
|
+
name = "colorama"
|
|
6
|
+
version = "0.4.6"
|
|
7
|
+
source = { registry = "https://pypi.org/simple" }
|
|
8
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 }
|
|
9
|
+
wheels = [
|
|
10
|
+
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[[package]]
|
|
14
|
+
name = "exceptiongroup"
|
|
15
|
+
version = "1.2.2"
|
|
16
|
+
source = { registry = "https://pypi.org/simple" }
|
|
17
|
+
sdist = { url = "https://files.pythonhosted.org/packages/09/35/2495c4ac46b980e4ca1f6ad6db102322ef3ad2410b79fdde159a4b0f3b92/exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc", size = 28883 }
|
|
18
|
+
wheels = [
|
|
19
|
+
{ url = "https://files.pythonhosted.org/packages/02/cc/b7e31358aac6ed1ef2bb790a9746ac2c69bcb3c8588b41616914eb106eaf/exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b", size = 16453 },
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[[package]]
|
|
23
|
+
name = "iniconfig"
|
|
24
|
+
version = "2.0.0"
|
|
25
|
+
source = { registry = "https://pypi.org/simple" }
|
|
26
|
+
sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
|
|
27
|
+
wheels = [
|
|
28
|
+
{ url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[[package]]
|
|
32
|
+
name = "packaging"
|
|
33
|
+
version = "24.1"
|
|
34
|
+
source = { registry = "https://pypi.org/simple" }
|
|
35
|
+
sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 }
|
|
36
|
+
wheels = [
|
|
37
|
+
{ url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 },
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[[package]]
|
|
41
|
+
name = "pluggy"
|
|
42
|
+
version = "1.5.0"
|
|
43
|
+
source = { registry = "https://pypi.org/simple" }
|
|
44
|
+
sdist = { url = "https://files.pythonhosted.org/packages/96/2d/02d4312c973c6050a18b314a5ad0b3210edb65a906f868e31c111dede4a6/pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", size = 67955 }
|
|
45
|
+
wheels = [
|
|
46
|
+
{ url = "https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669", size = 20556 },
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[[package]]
|
|
50
|
+
name = "pytest"
|
|
51
|
+
version = "8.3.3"
|
|
52
|
+
source = { registry = "https://pypi.org/simple" }
|
|
53
|
+
dependencies = [
|
|
54
|
+
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
|
55
|
+
{ name = "exceptiongroup", marker = "python_full_version < '3.11'" },
|
|
56
|
+
{ name = "iniconfig" },
|
|
57
|
+
{ name = "packaging" },
|
|
58
|
+
{ name = "pluggy" },
|
|
59
|
+
{ name = "tomli", marker = "python_full_version < '3.11'" },
|
|
60
|
+
]
|
|
61
|
+
sdist = { url = "https://files.pythonhosted.org/packages/8b/6c/62bbd536103af674e227c41a8f3dcd022d591f6eed5facb5a0f31ee33bbc/pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181", size = 1442487 }
|
|
62
|
+
wheels = [
|
|
63
|
+
{ url = "https://files.pythonhosted.org/packages/6b/77/7440a06a8ead44c7757a64362dd22df5760f9b12dc5f11b6188cd2fc27a0/pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2", size = 342341 },
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "sizestr"
|
|
68
|
+
version = "1.0.0"
|
|
69
|
+
source = { editable = "." }
|
|
70
|
+
|
|
71
|
+
[package.dev-dependencies]
|
|
72
|
+
dev = [
|
|
73
|
+
{ name = "pytest" },
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[package.metadata]
|
|
77
|
+
|
|
78
|
+
[package.metadata.requires-dev]
|
|
79
|
+
dev = [{ name = "pytest" }]
|
|
80
|
+
|
|
81
|
+
[[package]]
|
|
82
|
+
name = "tomli"
|
|
83
|
+
version = "2.0.1"
|
|
84
|
+
source = { registry = "https://pypi.org/simple" }
|
|
85
|
+
sdist = { url = "https://files.pythonhosted.org/packages/c0/3f/d7af728f075fb08564c5949a9c95e44352e23dee646869fa104a3b2060a3/tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f", size = 15164 }
|
|
86
|
+
wheels = [
|
|
87
|
+
{ url = "https://files.pythonhosted.org/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", size = 12757 },
|
|
88
|
+
]
|