githead 1.0.0__tar.gz → 1.2.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.
@@ -1,6 +1,11 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.1
2
2
  Name: githead
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
+ Summary: Simple utility for getting the current git commit hash (HEAD)
5
+ Author-email: Kamil Monicz <kamil@monicz.dev>
6
+ Project-URL: Issues, https://github.com/Zaczero/githead/issues
7
+ Project-URL: Repository, https://github.com/Zaczero/githead
8
+ Keywords: commit,git,git-commit,hash,head,vcs,version-control
4
9
  Classifier: Development Status :: 5 - Production/Stable
5
10
  Classifier: Intended Audience :: Developers
6
11
  Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
@@ -9,21 +14,12 @@ Classifier: Programming Language :: Python :: 3.10
9
14
  Classifier: Programming Language :: Python :: 3.11
10
15
  Classifier: Programming Language :: Python :: 3.12
11
16
  Classifier: Programming Language :: Python :: 3.13
12
- Classifier: Programming Language :: Python :: 3.8
13
17
  Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: Implementation :: CPython
15
- Classifier: Programming Language :: Python :: Implementation :: PyPy
16
- Classifier: Programming Language :: Rust
17
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
19
  Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
19
22
  License-File: LICENSE
20
- Summary: Simple utility for getting the current git commit hash
21
- Keywords: commit,git,hash,vcs,version-control
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/githead/issues
26
- Project-URL: Repository, https://github.com/Zaczero/githead
27
23
 
28
24
  # githead
29
25
 
@@ -31,12 +27,10 @@ Project-URL: Repository, https://github.com/Zaczero/githead
31
27
  [![Liberapay Patrons](https://shields.monicz.dev/liberapay/patrons/Zaczero?logo=liberapay&label=Patrons)](https://liberapay.com/Zaczero/)
32
28
  [![GitHub Sponsors](https://shields.monicz.dev/github/sponsors/Zaczero?logo=github&label=Sponsors&color=%23db61a2)](https://github.com/sponsors/Zaczero)
33
29
 
34
- Simple utility for getting the current git commit hash.
30
+ Simple utility for getting the current git commit hash (HEAD).
35
31
 
36
32
  ## Installation
37
33
 
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
34
  ```sh
41
35
  pip install githead
42
36
  ```
@@ -51,4 +45,3 @@ githead() # -> 'bca663418428d603eea8243d08a5ded19eb19a34'
51
45
  # defaults to '.git' directory but can be changed:
52
46
  githead('path/to/.git')
53
47
  ```
54
-
@@ -4,12 +4,10 @@
4
4
  [![Liberapay Patrons](https://shields.monicz.dev/liberapay/patrons/Zaczero?logo=liberapay&label=Patrons)](https://liberapay.com/Zaczero/)
5
5
  [![GitHub Sponsors](https://shields.monicz.dev/github/sponsors/Zaczero?logo=github&label=Sponsors&color=%23db61a2)](https://github.com/sponsors/Zaczero)
6
6
 
7
- Simple utility for getting the current git commit hash.
7
+ Simple utility for getting the current git commit hash (HEAD).
8
8
 
9
9
  ## Installation
10
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
11
  ```sh
14
12
  pip install githead
15
13
  ```
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ from typing import TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from os import PathLike
8
+
9
+
10
+ def githead(git_dir: PathLike[str] | str = '.git') -> str:
11
+ """Get the current git commit hash.
12
+
13
+ >>> githead()
14
+ 'bca663418428d603eea8243d08a5ded19eb19a34'
15
+ """
16
+ dir_path = Path(git_dir)
17
+ head_path = dir_path.joinpath('HEAD')
18
+ head = head_path.read_text().strip()
19
+
20
+ is_symbolic = head.startswith('ref: ')
21
+ if not is_symbolic:
22
+ return head
23
+
24
+ dir_abs = dir_path.resolve()
25
+ ref_abs = dir_abs.joinpath(head[5:]).resolve()
26
+ if not ref_abs.is_relative_to(dir_abs):
27
+ raise ValueError(f'HEAD references outside of {git_dir} directory')
28
+
29
+ ref = ref_abs.read_text().strip()
30
+ return ref
31
+
32
+
33
+ __all__ = ('githead',)
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.1
2
+ Name: githead
3
+ Version: 1.2.0
4
+ Summary: Simple utility for getting the current git commit hash (HEAD)
5
+ Author-email: Kamil Monicz <kamil@monicz.dev>
6
+ Project-URL: Issues, https://github.com/Zaczero/githead/issues
7
+ Project-URL: Repository, https://github.com/Zaczero/githead
8
+ Keywords: commit,git,git-commit,hash,head,vcs,version-control
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+
24
+ # githead
25
+
26
+ [![PyPI - Python Version](https://shields.monicz.dev/pypi/pyversions/githead)](https://pypi.org/project/githead)
27
+ [![Liberapay Patrons](https://shields.monicz.dev/liberapay/patrons/Zaczero?logo=liberapay&label=Patrons)](https://liberapay.com/Zaczero/)
28
+ [![GitHub Sponsors](https://shields.monicz.dev/github/sponsors/Zaczero?logo=github&label=Sponsors&color=%23db61a2)](https://github.com/sponsors/Zaczero)
29
+
30
+ Simple utility for getting the current git commit hash (HEAD).
31
+
32
+ ## Installation
33
+
34
+ ```sh
35
+ pip install githead
36
+ ```
37
+
38
+ ## Basic usage
39
+
40
+ ```py
41
+ from githead import githead
42
+
43
+ githead() # -> 'bca663418428d603eea8243d08a5ded19eb19a34'
44
+
45
+ # defaults to '.git' directory but can be changed:
46
+ githead('path/to/.git')
47
+ ```
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ githead/__init__.py
5
+ githead/py.typed
6
+ githead.egg-info/PKG-INFO
7
+ githead.egg-info/SOURCES.txt
8
+ githead.egg-info/dependency_links.txt
9
+ githead.egg-info/top_level.txt
10
+ tests/test___init__.py
@@ -0,0 +1 @@
1
+ githead
@@ -9,37 +9,38 @@ classifiers = [
9
9
  "Programming Language :: Python :: 3.11",
10
10
  "Programming Language :: Python :: 3.12",
11
11
  "Programming Language :: Python :: 3.13",
12
- "Programming Language :: Python :: 3.8",
13
12
  "Programming Language :: Python :: 3.9",
14
- "Programming Language :: Python :: Implementation :: CPython",
15
- "Programming Language :: Python :: Implementation :: PyPy",
16
- "Programming Language :: Rust",
17
13
  "Topic :: Software Development :: Libraries :: Python Modules",
18
14
  "Typing :: Typed",
19
15
  ]
20
16
  dependencies = []
21
- description = "Simple utility for getting the current git commit hash"
22
- dynamic = ["version"]
23
- keywords = ["commit", "git", "hash", "vcs", "version-control"]
17
+ description = "Simple utility for getting the current git commit hash (HEAD)"
18
+ keywords = [
19
+ "commit",
20
+ "git",
21
+ "git-commit",
22
+ "hash",
23
+ "head",
24
+ "vcs",
25
+ "version-control",
26
+ ]
24
27
  name = "githead"
25
28
  readme = "README.md"
26
- requires-python = ">=3.8"
29
+ requires-python = ">=3.9"
30
+ version = "1.2.0"
27
31
 
28
32
  [project.urls]
29
33
  Issues = "https://github.com/Zaczero/githead/issues"
30
34
  Repository = "https://github.com/Zaczero/githead"
31
35
 
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 = "githead._lib"
39
- python-source = "python"
40
-
41
36
  [tool.uv]
42
37
  dev-dependencies = ["pytest"]
38
+ package = true
39
+ python-downloads = "never"
40
+ python-preference = "only-system"
41
+
42
+ [tool.setuptools]
43
+ packages = ["githead"]
43
44
 
44
45
  [tool.ruff]
45
46
  exclude = [
@@ -53,11 +54,10 @@ exclude = [
53
54
  ]
54
55
 
55
56
  indent-width = 4
56
- line-length = 120
57
- target-version = "py38"
57
+ line-length = 88
58
+ target-version = "py39"
58
59
 
59
60
  [tool.ruff.lint]
60
- # custom + https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
61
61
  ignore = [
62
62
  "B017", # assert-raises-exception
63
63
  "COM812", # missing-trailing-comma
@@ -80,7 +80,7 @@ ignore = [
80
80
  "TRY003", # raise-vanilla-args
81
81
  "W191", # tab-indentation
82
82
  ]
83
- # see https://docs.astral.sh/ruff/rules/ for rules documentation
83
+ # see https://docs.astral.sh/ruff/rules/
84
84
  select = [
85
85
  "A", # flake8-builtins
86
86
  "ARG", # flake8-unused-arguments
@@ -93,7 +93,8 @@ select = [
93
93
  "E9",
94
94
  "F", # pyflakes
95
95
  "FA", # flake8-future-annotations
96
- "FLY", # flynt # "FURB", # refurb
96
+ "FLY", # flynt
97
+ "FURB", # refurb
97
98
  "G", # flake8-logging-format
98
99
  "I", # isort
99
100
  "ICN", # flake8-import-conventions
@@ -104,6 +105,10 @@ select = [
104
105
  "NPY", # numpy
105
106
  "PERF", # perflint
106
107
  "PIE", # flake8-pie
108
+ "PLC", # pylint
109
+ "PLE", # pylint
110
+ "PLR", # pylint
111
+ "PLW", # pylint
107
112
  "PT", # flake8-pytest-style
108
113
  "PTH", # flake8-use-pathlib
109
114
  "PYI", # flake8-pyi
@@ -115,6 +120,7 @@ select = [
115
120
  "SLF", # flake8-self
116
121
  "SLOT", # flake8-slots
117
122
  "T10", # flake8-debugger
123
+ "TCH", # flake8-type-checking
118
124
  "TID", # flake8-tidy-imports
119
125
  "TRY", # tryceratops
120
126
  "UP", # pyupgrade
@@ -122,22 +128,15 @@ select = [
122
128
  "YTT", # flake8-2020
123
129
  ]
124
130
 
125
- # allow fix for all enabled rules (when `--fix`) is provided.
126
131
  fixable = ["ALL"]
127
132
  unfixable = []
128
133
 
129
- # allow unused variables when underscore-prefixed.
130
- dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
131
-
132
134
  [tool.ruff.format]
133
135
  indent-style = "space"
134
136
  line-ending = "lf"
135
137
  quote-style = "single"
136
138
  skip-magic-trailing-comma = false
137
139
 
138
- [tool.ruff.lint.flake8-builtins]
139
- builtins-ignorelist = ["input"]
140
-
141
140
  [tool.ruff.lint.flake8-quotes]
142
141
  docstring-quotes = "double"
143
142
  inline-quotes = "single"
@@ -147,10 +146,10 @@ multiline-quotes = "double"
147
146
  max-args = 10
148
147
 
149
148
  [tool.pyright]
150
- include = ["python/githead", "tests"]
149
+ include = ["githead", "tests"]
151
150
  pythonPlatform = "All"
152
- pythonVersion = "3.8"
153
- strict = ["python/githead"]
151
+ pythonVersion = "3.9"
152
+ strict = ["githead"]
154
153
 
155
154
  [tool.pytest.ini_options]
156
155
  addopts = "--quiet"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,6 +1,7 @@
1
1
  from pathlib import Path
2
2
 
3
3
  import pytest
4
+
4
5
  from githead import githead
5
6
 
6
7
  GIT_PATH = Path('tests/git')
@@ -31,5 +32,7 @@ def test_reference_not_found():
31
32
 
32
33
  def test_reference_outside_git():
33
34
  HEAD_PATH.write_text('ref: ../test___init__.py\n')
34
- with pytest.raises(ValueError, match='HEAD references outside of .git directory'):
35
+ with pytest.raises(
36
+ ValueError, match='HEAD references outside of tests/git directory'
37
+ ):
35
38
  githead(GIT_PATH)
githead-1.0.0/.envrc DELETED
@@ -1,3 +0,0 @@
1
- # shellcheck disable=SC2148
2
-
3
- use nix
@@ -1,2 +0,0 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
@@ -1,224 +0,0 @@
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: Install dependencies
55
- run: |
56
- nix-shell --run true
57
-
58
- - name: Export Nix store cache
59
- if: steps.nix-cache.outputs.cache-hit != 'true'
60
- run: |
61
- nix-store --export $(find /nix/store -maxdepth 1 -name '*-*') > /tmp/nix-cache
62
-
63
- - name: Assert tag name matches version
64
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
65
- run: |
66
- nix-shell --pure --run "uv tree 2>&1 | grep -o 'githead v.*' | sed 's/githead v//' > version.txt"
67
- version=$(cat version.txt)
68
- tag_name=${{ github.ref_name }}
69
- if [ "$version" != "$tag_name" ]; then
70
- echo "Tag name mismatch: $version != $tag_name"
71
- exit 1
72
- fi
73
-
74
- - name: Run tests
75
- run: |
76
- nix-shell --pure --run run-tests
77
-
78
- linux:
79
- runs-on: ${{ matrix.platform.runner }}
80
- if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
81
- needs: test
82
- strategy:
83
- matrix:
84
- platform:
85
- - runner: ubuntu-latest
86
- target: x86_64
87
- - runner: ubuntu-latest
88
- target: aarch64
89
- steps:
90
- - uses: actions/checkout@v4
91
- - uses: actions/setup-python@v5
92
- with:
93
- python-version: 3.x
94
- - name: Build wheels
95
- uses: PyO3/maturin-action@v1
96
- with:
97
- target: ${{ matrix.platform.target }}
98
- args: --release --out dist --zig
99
- sccache: "true"
100
- manylinux: auto
101
- - name: Upload wheels
102
- uses: actions/upload-artifact@v4
103
- with:
104
- name: wheels-linux-${{ matrix.platform.target }}
105
- path: dist
106
-
107
- musllinux:
108
- runs-on: ${{ matrix.platform.runner }}
109
- if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
110
- needs: test
111
- strategy:
112
- matrix:
113
- platform:
114
- - runner: ubuntu-latest
115
- target: x86_64
116
- - runner: ubuntu-latest
117
- target: aarch64
118
- steps:
119
- - uses: actions/checkout@v4
120
- - uses: actions/setup-python@v5
121
- with:
122
- python-version: 3.x
123
- - name: Build wheels
124
- uses: PyO3/maturin-action@v1
125
- with:
126
- target: ${{ matrix.platform.target }}
127
- args: --release --out dist
128
- sccache: "true"
129
- manylinux: musllinux_1_2
130
- - name: Upload wheels
131
- uses: actions/upload-artifact@v4
132
- with:
133
- name: wheels-musllinux-${{ matrix.platform.target }}
134
- path: dist
135
-
136
- windows:
137
- runs-on: ${{ matrix.platform.runner }}
138
- if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
139
- needs: test
140
- strategy:
141
- matrix:
142
- platform:
143
- - runner: windows-latest
144
- target: x64
145
- steps:
146
- - uses: actions/checkout@v4
147
- - uses: actions/setup-python@v5
148
- with:
149
- python-version: 3.x
150
- architecture: ${{ matrix.platform.target }}
151
- - name: Build wheels
152
- uses: PyO3/maturin-action@v1
153
- with:
154
- target: ${{ matrix.platform.target }}
155
- args: --release --out dist
156
- sccache: "true"
157
- - name: Upload wheels
158
- uses: actions/upload-artifact@v4
159
- with:
160
- name: wheels-windows-${{ matrix.platform.target }}
161
- path: dist
162
-
163
- macos:
164
- runs-on: ${{ matrix.platform.runner }}
165
- if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
166
- needs: test
167
- strategy:
168
- matrix:
169
- platform:
170
- - runner: macos-12
171
- target: x86_64
172
- - runner: macos-14
173
- target: aarch64
174
- steps:
175
- - uses: actions/checkout@v4
176
- - uses: actions/setup-python@v5
177
- with:
178
- python-version: 3.x
179
- - name: Build wheels
180
- uses: PyO3/maturin-action@v1
181
- with:
182
- target: ${{ matrix.platform.target }}
183
- args: --release --out dist
184
- sccache: "true"
185
- - name: Upload wheels
186
- uses: actions/upload-artifact@v4
187
- with:
188
- name: wheels-macos-${{ matrix.platform.target }}
189
- path: dist
190
-
191
- sdist:
192
- runs-on: ubuntu-latest
193
- needs: test
194
- steps:
195
- - uses: actions/checkout@v4
196
- - name: Build sdist
197
- uses: PyO3/maturin-action@v1
198
- with:
199
- command: sdist
200
- args: --out dist
201
- - name: Upload sdist
202
- uses: actions/upload-artifact@v4
203
- with:
204
- name: wheels-sdist
205
- path: dist
206
-
207
- release:
208
- name: Release
209
- runs-on: ubuntu-latest
210
- if: "github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')"
211
- needs: [linux, musllinux, windows, macos, sdist]
212
- environment:
213
- name: pypi
214
- url: https://pypi.org/p/githead
215
- permissions:
216
- id-token: write
217
- steps:
218
- - uses: actions/download-artifact@v4
219
- with:
220
- pattern: wheels-*
221
- path: dist
222
- merge-multiple: true
223
- - name: Publish to PyPI
224
- uses: pypa/gh-action-pypi-publish@release/v1
githead-1.0.0/.gitignore DELETED
@@ -1,221 +0,0 @@
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.*
220
-
221
- tests/git/HEAD
@@ -1,7 +0,0 @@
1
- {
2
- "python.testing.pytestArgs": [
3
- "tests"
4
- ],
5
- "python.testing.unittestEnabled": false,
6
- "python.testing.pytestEnabled": true
7
- }
githead-1.0.0/Cargo.lock DELETED
@@ -1,171 +0,0 @@
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 = "githead"
19
- version = "1.0.0"
20
- dependencies = [
21
- "pyo3",
22
- ]
23
-
24
- [[package]]
25
- name = "heck"
26
- version = "0.5.0"
27
- source = "registry+https://github.com/rust-lang/crates.io-index"
28
- checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
29
-
30
- [[package]]
31
- name = "indoc"
32
- version = "2.0.5"
33
- source = "registry+https://github.com/rust-lang/crates.io-index"
34
- checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
35
-
36
- [[package]]
37
- name = "libc"
38
- version = "0.2.158"
39
- source = "registry+https://github.com/rust-lang/crates.io-index"
40
- checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
41
-
42
- [[package]]
43
- name = "memoffset"
44
- version = "0.9.1"
45
- source = "registry+https://github.com/rust-lang/crates.io-index"
46
- checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
47
- dependencies = [
48
- "autocfg",
49
- ]
50
-
51
- [[package]]
52
- name = "once_cell"
53
- version = "1.19.0"
54
- source = "registry+https://github.com/rust-lang/crates.io-index"
55
- checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
56
-
57
- [[package]]
58
- name = "portable-atomic"
59
- version = "1.8.0"
60
- source = "registry+https://github.com/rust-lang/crates.io-index"
61
- checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce"
62
-
63
- [[package]]
64
- name = "proc-macro2"
65
- version = "1.0.86"
66
- source = "registry+https://github.com/rust-lang/crates.io-index"
67
- checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
68
- dependencies = [
69
- "unicode-ident",
70
- ]
71
-
72
- [[package]]
73
- name = "pyo3"
74
- version = "0.22.3"
75
- source = "registry+https://github.com/rust-lang/crates.io-index"
76
- checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225"
77
- dependencies = [
78
- "cfg-if",
79
- "indoc",
80
- "libc",
81
- "memoffset",
82
- "once_cell",
83
- "portable-atomic",
84
- "pyo3-build-config",
85
- "pyo3-ffi",
86
- "pyo3-macros",
87
- "unindent",
88
- ]
89
-
90
- [[package]]
91
- name = "pyo3-build-config"
92
- version = "0.22.3"
93
- source = "registry+https://github.com/rust-lang/crates.io-index"
94
- checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3"
95
- dependencies = [
96
- "once_cell",
97
- "target-lexicon",
98
- ]
99
-
100
- [[package]]
101
- name = "pyo3-ffi"
102
- version = "0.22.3"
103
- source = "registry+https://github.com/rust-lang/crates.io-index"
104
- checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c"
105
- dependencies = [
106
- "libc",
107
- "pyo3-build-config",
108
- ]
109
-
110
- [[package]]
111
- name = "pyo3-macros"
112
- version = "0.22.3"
113
- source = "registry+https://github.com/rust-lang/crates.io-index"
114
- checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28"
115
- dependencies = [
116
- "proc-macro2",
117
- "pyo3-macros-backend",
118
- "quote",
119
- "syn",
120
- ]
121
-
122
- [[package]]
123
- name = "pyo3-macros-backend"
124
- version = "0.22.3"
125
- source = "registry+https://github.com/rust-lang/crates.io-index"
126
- checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1"
127
- dependencies = [
128
- "heck",
129
- "proc-macro2",
130
- "pyo3-build-config",
131
- "quote",
132
- "syn",
133
- ]
134
-
135
- [[package]]
136
- name = "quote"
137
- version = "1.0.37"
138
- source = "registry+https://github.com/rust-lang/crates.io-index"
139
- checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
140
- dependencies = [
141
- "proc-macro2",
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"
githead-1.0.0/Cargo.toml DELETED
@@ -1,14 +0,0 @@
1
- [package]
2
- edition = "2021"
3
- name = "githead"
4
- version = "1.0.0"
5
-
6
- [lib]
7
- crate-type = ["cdylib"]
8
- name = "githead"
9
-
10
- [dependencies]
11
- pyo3 = { version = "0.22.2", features = ["abi3-py38", "extension-module"] }
12
-
13
- [profile.release]
14
- overflow-checks = true
@@ -1,5 +0,0 @@
1
- from githead._lib import githead
2
-
3
- __all__ = [
4
- 'githead',
5
- ]
@@ -1,9 +0,0 @@
1
- from os import PathLike
2
-
3
- def githead(dir_: PathLike[str] | str = '.git') -> str:
4
- """
5
- Get the current git commit hash.
6
-
7
- >>> githead()
8
- 'bca663418428d603eea8243d08a5ded19eb19a34'
9
- """
githead-1.0.0/shell.nix DELETED
@@ -1,52 +0,0 @@
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
- }
githead-1.0.0/src/lib.rs DELETED
@@ -1,38 +0,0 @@
1
- use pyo3::{exceptions::PyValueError, prelude::*};
2
- use std::{
3
- fs::{self},
4
- path::PathBuf,
5
- str::FromStr,
6
- };
7
-
8
- #[pyfunction]
9
- #[pyo3(signature = (dir_ = PathBuf::from(".git")))]
10
- fn githead(dir_: PathBuf) -> PyResult<String> {
11
- let head_path: PathBuf = dir_.join("HEAD");
12
- let head_raw = fs::read_to_string(head_path)?;
13
- let head = head_raw.trim_end();
14
-
15
- let is_symbolic = head.starts_with("ref: ");
16
- if !is_symbolic {
17
- return Ok(String::from_str(head)?);
18
- }
19
-
20
- let dir_abs = fs::canonicalize(dir_)?;
21
- let ref_abs = fs::canonicalize(dir_abs.join(&head[5..]))?;
22
- if !ref_abs.ancestors().any(|p| p == dir_abs) {
23
- return Err(PyValueError::new_err(
24
- "HEAD references outside of .git directory",
25
- ));
26
- }
27
-
28
- let ref_raw = fs::read_to_string(ref_abs)?;
29
- let ref_ = ref_raw.trim_end();
30
- Ok(String::from_str(ref_)?)
31
- }
32
-
33
- #[pymodule]
34
- #[pyo3(name = "_lib")]
35
- fn lib(m: &Bound<'_, PyModule>) -> PyResult<()> {
36
- m.add_function(wrap_pyfunction!(githead, m)?)?;
37
- Ok(())
38
- }
@@ -1 +0,0 @@
1
- bar
githead-1.0.0/uv.lock DELETED
@@ -1,88 +0,0 @@
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 = "githead"
24
- version = "1.0.0"
25
- source = { editable = "." }
26
-
27
- [package.dev-dependencies]
28
- dev = [
29
- { name = "pytest" },
30
- ]
31
-
32
- [package.metadata]
33
-
34
- [package.metadata.requires-dev]
35
- dev = [{ name = "pytest" }]
36
-
37
- [[package]]
38
- name = "iniconfig"
39
- version = "2.0.0"
40
- source = { registry = "https://pypi.org/simple" }
41
- sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 }
42
- wheels = [
43
- { url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 },
44
- ]
45
-
46
- [[package]]
47
- name = "packaging"
48
- version = "24.1"
49
- source = { registry = "https://pypi.org/simple" }
50
- sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 }
51
- wheels = [
52
- { url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 },
53
- ]
54
-
55
- [[package]]
56
- name = "pluggy"
57
- version = "1.5.0"
58
- source = { registry = "https://pypi.org/simple" }
59
- sdist = { url = "https://files.pythonhosted.org/packages/96/2d/02d4312c973c6050a18b314a5ad0b3210edb65a906f868e31c111dede4a6/pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", size = 67955 }
60
- wheels = [
61
- { url = "https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669", size = 20556 },
62
- ]
63
-
64
- [[package]]
65
- name = "pytest"
66
- version = "8.3.3"
67
- source = { registry = "https://pypi.org/simple" }
68
- dependencies = [
69
- { name = "colorama", marker = "sys_platform == 'win32'" },
70
- { name = "exceptiongroup", marker = "python_full_version < '3.11'" },
71
- { name = "iniconfig" },
72
- { name = "packaging" },
73
- { name = "pluggy" },
74
- { name = "tomli", marker = "python_full_version < '3.11'" },
75
- ]
76
- sdist = { url = "https://files.pythonhosted.org/packages/8b/6c/62bbd536103af674e227c41a8f3dcd022d591f6eed5facb5a0f31ee33bbc/pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181", size = 1442487 }
77
- wheels = [
78
- { url = "https://files.pythonhosted.org/packages/6b/77/7440a06a8ead44c7757a64362dd22df5760f9b12dc5f11b6188cd2fc27a0/pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2", size = 342341 },
79
- ]
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
- ]
File without changes
File without changes