pre-commit-uv 4.0.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,68 @@
1
+ """Package root."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ import os
7
+ from functools import cache
8
+ from importlib.metadata import version as _metadata_version
9
+ from typing import TYPE_CHECKING, cast
10
+
11
+ from pre_commit import lang_base, main
12
+ from pre_commit.languages import python
13
+ from pre_commit.languages.python import in_env, norm_version
14
+ from pre_commit.util import CalledProcessError, cmd_output, cmd_output_b
15
+ from uv import find_uv_bin
16
+
17
+ if TYPE_CHECKING:
18
+ from collections.abc import Sequence
19
+
20
+ from pre_commit.prefix import Prefix
21
+
22
+
23
+ __version__ = _metadata_version("pre-commit-uv")
24
+ _uv_version = _metadata_version("uv")
25
+ _original_main = main.main
26
+
27
+
28
+ def _patch() -> None:
29
+ if os.environ.get("DISABLE_PRE_COMMIT_UV_PATCH") is None:
30
+ main.main = _new_main
31
+
32
+
33
+ def _new_main(argv: Sequence[str] | None = None) -> int:
34
+ python.install_environment = _install_environment
35
+ python._version_info = _version_info # noqa: SLF001
36
+ return cast(int, _original_main(argv))
37
+
38
+
39
+ def _install_environment(
40
+ prefix: Prefix,
41
+ version: str,
42
+ additional_dependencies: Sequence[str],
43
+ ) -> None:
44
+ logging.getLogger("pre_commit").info("Using pre-commit with uv %s via pre-commit-uv %s", _uv_version, __version__)
45
+ uv = find_uv_bin()
46
+
47
+ venv_cmd = [uv, "venv", lang_base.environment_dir(prefix, python.ENVIRONMENT_DIR, version)]
48
+ py = norm_version(version)
49
+ if py is not None:
50
+ venv_cmd.extend(("-p", py))
51
+ cmd_output_b(*venv_cmd, cwd="/")
52
+
53
+ with in_env(prefix, version):
54
+ lang_base.setup_cmd(prefix, (uv, "pip", "install", ".", *additional_dependencies))
55
+
56
+
57
+ @cache
58
+ def _version_info(exe: str) -> str:
59
+ prog = 'import sys;print(".".join(str(p) for p in sys.version_info[0:3]))'
60
+ try:
61
+ return cast(str, cmd_output(exe, "-S", "-c", prog)[1].strip())
62
+ except CalledProcessError:
63
+ return f"<<error retrieving version from {exe}>>"
64
+
65
+
66
+ __all__ = [
67
+ "__version__",
68
+ ]
pre_commit_uv/py.typed ADDED
File without changes
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.3
2
+ Name: pre-commit-uv
3
+ Version: 4.0.0
4
+ Summary: Run pre-commit with uv
5
+ Project-URL: Bug Tracker, https://github.com/tox-dev/pre-commit-uv/issues
6
+ Project-URL: Changelog, https://github.com/tox-dev/pre-commit-uv/releases
7
+ Project-URL: Documentation, https://github.com/tox-dev/pre-commit-uv/
8
+ Project-URL: Source Code, https://github.com/tox-dev/pre-commit-uv
9
+ Author-email: Bernat Gabor <gaborjbernat@gmail.com>
10
+ License: Permission is hereby granted, free of charge, to any person obtaining a
11
+ copy of this software and associated documentation files (the
12
+ "Software"), to deal in the Software without restriction, including
13
+ without limitation the rights to use, copy, modify, merge, publish,
14
+ distribute, sublicense, and/or sell copies of the Software, and to
15
+ permit persons to whom the Software is furnished to do so, subject to
16
+ the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included
19
+ in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
+ License-File: LICENSE.txt
29
+ Keywords: format,pyproject
30
+ Classifier: License :: OSI Approved :: MIT License
31
+ Classifier: Operating System :: OS Independent
32
+ Classifier: Programming Language :: Python
33
+ Classifier: Programming Language :: Python :: 3 :: Only
34
+ Classifier: Programming Language :: Python :: 3.9
35
+ Classifier: Programming Language :: Python :: 3.10
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Requires-Python: >=3.9
39
+ Requires-Dist: pre-commit>=3.8
40
+ Requires-Dist: uv>=0.2.33
41
+ Provides-Extra: test
42
+ Requires-Dist: covdefaults>=2.3; extra == 'test'
43
+ Requires-Dist: pytest-cov>=5; extra == 'test'
44
+ Requires-Dist: pytest-mock>=3.14; extra == 'test'
45
+ Requires-Dist: pytest>=8.3.2; extra == 'test'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # pre-commit-uv
49
+
50
+ [![PyPI](https://img.shields.io/pypi/v/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
51
+ [![PyPI - Implementation](https://img.shields.io/pypi/implementation/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
52
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pre-commit-uv?style=flat-square)](https://pypi.org/project/pre-commit-uv)
53
+ [![Downloads](https://static.pepy.tech/badge/pre-commit-uv/month)](https://pepy.tech/project/pre-commit-uv)
54
+ [![PyPI - License](https://img.shields.io/pypi/l/pre-commit-uv?style=flat-square)](https://opensource.org/licenses/MIT)
55
+ [![check](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml/badge.svg)](https://github.com/tox-dev/pre-commit-uv/actions/workflows/check.yml)
56
+
57
+ Use `uv` to create virtual environments and install packages for `pre-commit`.
58
+
59
+ ## Configuration
60
+
61
+ Once installed will use `uv` out of box, however the `DISABLE_PRE_COMMIT_UV_PATCH` environment variable if set will work as an escape hatch.
@@ -0,0 +1,7 @@
1
+ pre_commit_uv/__init__.py,sha256=t5Pzui2YokwlsBaw7m-JrCbOm_7RqDb_866Rh0nio_U,1938
2
+ pre_commit_uv/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ pre_commit_uv_patch.pth,sha256=qMjEbKQy7WyQXfdjta-wzLnAkKDEc8KcWq-3UOzdXNw,45
4
+ pre_commit_uv-4.0.0.dist-info/METADATA,sha256=a-UzMrHcmx_EDbjWKlJtoadOrxIDvcRlaECWF3QJDWI,3421
5
+ pre_commit_uv-4.0.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
6
+ pre_commit_uv-4.0.0.dist-info/licenses/LICENSE.txt,sha256=kOJeH68qSq6o2V7o5_VziwUqGswMnFgGgQH5Mahr1Yg,1023
7
+ pre_commit_uv-4.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.25.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining a
2
+ copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included
10
+ in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ import pre_commit_uv; pre_commit_uv._patch()