1 |
commit: 37fe831d60f51bd1d43c3ff6c34510e78d99ade4 |
2 |
Author: Marek Szuba <marecki <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 30 00:28:19 2022 +0000 |
4 |
Commit: Marek Szuba <marecki <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 30 00:31:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=37fe831d |
7 |
|
8 |
dev-vcs/pre-commit: drop dependency on dev-python/toml |
9 |
|
10 |
Backported to 2.20.0 from upstream Git master branch. |
11 |
|
12 |
Bug: https://bugs.gentoo.org/878677 |
13 |
Signed-off-by: Marek Szuba <marecki <AT> gentoo.org> |
14 |
|
15 |
dev-vcs/pre-commit/Manifest | 1 + |
16 |
.../files/pre-commit-2.20.0-no_toml.patch | 81 ++++++++++++++++++++++ |
17 |
dev-vcs/pre-commit/pre-commit-2.20.0-r1.ebuild | 54 +++++++++++++++ |
18 |
3 files changed, 136 insertions(+) |
19 |
|
20 |
diff --git a/dev-vcs/pre-commit/Manifest b/dev-vcs/pre-commit/Manifest |
21 |
index 06a74933c9d1..c43c785bb1aa 100644 |
22 |
--- a/dev-vcs/pre-commit/Manifest |
23 |
+++ b/dev-vcs/pre-commit/Manifest |
24 |
@@ -1 +1,2 @@ |
25 |
+DIST pre-commit-2.20.0.gh.tar.gz 266604 BLAKE2B 470f032e6d5bfcdd9ac8ba8f37d4323b601da0c82bcd524ffc575dc688fe81ad326a1f6a8ddd03da6e37130319ee40070c03d9789cd6e0e4b427a1d6e646416e SHA512 b1da558a0e5d8f2f655427089f1d0b11b01ad7513ece7a0b3b67c33529cf3584edba558c78704e6da6ca18876b1d6c0fa8698e01fd7c2439b8d4dc0a93961e52 |
26 |
DIST pre-commit-2.20.0.tar.gz 266604 BLAKE2B 470f032e6d5bfcdd9ac8ba8f37d4323b601da0c82bcd524ffc575dc688fe81ad326a1f6a8ddd03da6e37130319ee40070c03d9789cd6e0e4b427a1d6e646416e SHA512 b1da558a0e5d8f2f655427089f1d0b11b01ad7513ece7a0b3b67c33529cf3584edba558c78704e6da6ca18876b1d6c0fa8698e01fd7c2439b8d4dc0a93961e52 |
27 |
|
28 |
diff --git a/dev-vcs/pre-commit/files/pre-commit-2.20.0-no_toml.patch b/dev-vcs/pre-commit/files/pre-commit-2.20.0-no_toml.patch |
29 |
new file mode 100644 |
30 |
index 000000000000..f7f335c29e14 |
31 |
--- /dev/null |
32 |
+++ b/dev-vcs/pre-commit/files/pre-commit-2.20.0-no_toml.patch |
33 |
@@ -0,0 +1,81 @@ |
34 |
+Backported upstream commit e703982de45ac64492897b25fa4edbdb8da10e62. |
35 |
+ |
36 |
+--- a/pre_commit/languages/rust.py |
37 |
++++ b/pre_commit/languages/rust.py |
38 |
+@@ -5,8 +5,6 @@ |
39 |
+ from typing import Generator |
40 |
+ from typing import Sequence |
41 |
+ |
42 |
+-import toml |
43 |
+- |
44 |
+ import pre_commit.constants as C |
45 |
+ from pre_commit.envcontext import envcontext |
46 |
+ from pre_commit.envcontext import PatchesT |
47 |
+@@ -38,18 +36,16 @@ |
48 |
+ |
49 |
+ |
50 |
+ def _add_dependencies( |
51 |
+- cargo_toml_path: str, |
52 |
++ prefix: Prefix, |
53 |
+ additional_dependencies: set[str], |
54 |
+ ) -> None: |
55 |
+- with open(cargo_toml_path, 'r+') as f: |
56 |
+- cargo_toml = toml.load(f) |
57 |
+- cargo_toml.setdefault('dependencies', {}) |
58 |
+- for dep in additional_dependencies: |
59 |
+- name, _, spec = dep.partition(':') |
60 |
+- cargo_toml['dependencies'][name] = spec or '*' |
61 |
+- f.seek(0) |
62 |
+- toml.dump(cargo_toml, f) |
63 |
+- f.truncate() |
64 |
++ crates = [] |
65 |
++ for dep in additional_dependencies: |
66 |
++ name, _, spec = dep.partition(':') |
67 |
++ crate = f'{name}@{spec or "*"}' |
68 |
++ crates.append(crate) |
69 |
++ |
70 |
++ helpers.run_setup_cmd(prefix, ('cargo', 'add', *crates)) |
71 |
+ |
72 |
+ |
73 |
+ def install_environment( |
74 |
+@@ -77,9 +73,6 @@ |
75 |
+ } |
76 |
+ lib_deps = set(additional_dependencies) - cli_deps |
77 |
+ |
78 |
+- if len(lib_deps) > 0: |
79 |
+- _add_dependencies(prefix.path('Cargo.toml'), lib_deps) |
80 |
+- |
81 |
+ with clean_path_on_failure(directory): |
82 |
+ packages_to_install: set[tuple[str, ...]] = {('--path', '.')} |
83 |
+ for cli_dep in cli_deps: |
84 |
+@@ -90,6 +83,9 @@ |
85 |
+ else: |
86 |
+ packages_to_install.add((package,)) |
87 |
+ |
88 |
++ if len(lib_deps) > 0: |
89 |
++ _add_dependencies(prefix, lib_deps) |
90 |
++ |
91 |
+ for args in packages_to_install: |
92 |
+ cmd_output_b( |
93 |
+ 'cargo', 'install', '--bins', '--root', directory, *args, |
94 |
+--- a/setup.cfg |
95 |
++++ b/setup.cfg |
96 |
+@@ -27,7 +27,6 @@ |
97 |
+ identify>=1.0.0 |
98 |
+ nodeenv>=0.11.1 |
99 |
+ pyyaml>=5.1 |
100 |
+- toml |
101 |
+ virtualenv>=20.0.8 |
102 |
+ importlib-metadata;python_version<"3.8" |
103 |
+ python_requires = >=3.7 |
104 |
+--- a/tests/repository_test.py |
105 |
++++ b/tests/repository_test.py |
106 |
+@@ -485,7 +485,7 @@ |
107 |
+ path = make_repo(tempdir_factory, 'rust_hooks_repo') |
108 |
+ config = make_config_from_repo(path) |
109 |
+ # A small rust package with no dependencies. |
110 |
+- deps = ['shellharden:3.1.0'] |
111 |
++ deps = ['shellharden:3.1.0', 'git-version'] |
112 |
+ config['hooks'][0]['additional_dependencies'] = deps |
113 |
+ hook = _get_hook(config, store, 'rust-hook') |
114 |
+ binaries = os.listdir( |
115 |
|
116 |
diff --git a/dev-vcs/pre-commit/pre-commit-2.20.0-r1.ebuild b/dev-vcs/pre-commit/pre-commit-2.20.0-r1.ebuild |
117 |
new file mode 100644 |
118 |
index 000000000000..5c803594ede5 |
119 |
--- /dev/null |
120 |
+++ b/dev-vcs/pre-commit/pre-commit-2.20.0-r1.ebuild |
121 |
@@ -0,0 +1,54 @@ |
122 |
+# Copyright 1999-2022 Gentoo Authors |
123 |
+# Distributed under the terms of the GNU General Public License v2 |
124 |
+ |
125 |
+EAPI=8 |
126 |
+ |
127 |
+PYTHON_COMPAT=( python3_{8..11} ) |
128 |
+DISTUTILS_SINGLE_IMPL=1 |
129 |
+DISTUTILS_USE_PEP517=setuptools |
130 |
+PYTHON_REQ_USE="sqlite" |
131 |
+ |
132 |
+inherit distutils-r1 |
133 |
+ |
134 |
+DESCRIPTION="A framework for managing and maintaining multi-language Git pre-commit hooks" |
135 |
+HOMEPAGE="https://pre-commit.com/" |
136 |
+SRC_URI="https://github.com/${PN}/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.gh.tar.gz" |
137 |
+ |
138 |
+LICENSE="MIT" |
139 |
+SLOT="0" |
140 |
+KEYWORDS="~amd64 ~hppa ~ppc ~ppc64 ~x86" |
141 |
+ |
142 |
+RDEPEND="dev-vcs/git |
143 |
+ $(python_gen_cond_dep ' |
144 |
+ >=dev-python/cfgv-2.0.0[${PYTHON_USEDEP}] |
145 |
+ >=dev-python/identify-1.0.0[${PYTHON_USEDEP}] |
146 |
+ >=dev-python/nodeenv-0.11.1[${PYTHON_USEDEP}] |
147 |
+ >=dev-python/pyyaml-5.1[${PYTHON_USEDEP}] |
148 |
+ >=dev-python/virtualenv-20.0.8[${PYTHON_USEDEP}] |
149 |
+ ')" |
150 |
+BDEPEND="test? ( |
151 |
+ $(python_gen_cond_dep ' |
152 |
+ dev-python/pytest-env[${PYTHON_USEDEP}] |
153 |
+ dev-python/re-assert[${PYTHON_USEDEP}] |
154 |
+ ') |
155 |
+)" |
156 |
+ |
157 |
+PATCHES=( |
158 |
+ "${FILESDIR}"/${PN}-2.20.0-no_toml.patch |
159 |
+) |
160 |
+ |
161 |
+DOCS=( CHANGELOG.md CONTRIBUTING.md README.md ) |
162 |
+ |
163 |
+# The former two require a boatload of dependencies (e.g. Conda, Go, R and more) in order to run |
164 |
+# and while some of them do include "skip if not found" logic, most of them do not. |
165 |
+# The latter consistently fail with |
166 |
+# Calling "git rev-parse" fails with "fatal: not a git repository (or any of the parent directories): .git". |
167 |
+# including with the sandbox disabled and when run manually with tox. |
168 |
+EPYTEST_DESELECT=( |
169 |
+ tests/languages/ |
170 |
+ tests/repository_test.py |
171 |
+ tests/main_test.py::test_all_cmds |
172 |
+ tests/main_test.py::test_try_repo |
173 |
+) |
174 |
+ |
175 |
+distutils_enable_tests pytest |