···45let
6 python' = python3.override {
7- packageOverrides = self: super: rec {
8 # tvdb_api v3.1.0 has a hard requirement on requests-cache < 0.6
9- requests-cache = super.requests-cache.overridePythonAttrs (super: rec {
10 version = "0.5.2";
11- src = self.fetchPypi {
12- inherit (super) pname;
13 inherit version;
14 sha256 = "sha256-gTAjJpaGBF+OAeIonMHn6a5asi3dHihJqQk6s6tycOs=";
15 };
00001617 # too many changes have been made to requests-cache based on version 0.6 so
18 # simply disable tests
···45let
6 python' = python3.override {
7+ packageOverrides = final: prev: rec {
8 # tvdb_api v3.1.0 has a hard requirement on requests-cache < 0.6
9+ requests-cache = prev.requests-cache.overridePythonAttrs (oldAttrs: rec {
10 version = "0.5.2";
11+ src = final.fetchPypi {
12+ inherit (oldAttrs) pname;
13 inherit version;
14 sha256 = "sha256-gTAjJpaGBF+OAeIonMHn6a5asi3dHihJqQk6s6tycOs=";
15 };
16+17+ nativeBuildInputs = with final; [
18+ setuptools
19+ ];
2021 # too many changes have been made to requests-cache based on version 0.6 so
22 # simply disable tests
···1+# this module only has to exist because cpython has a global interpreter lock
2+# and markdown-it is pure python code. ideally we'd just use thread pools, but
3+# the GIL prohibits this.
4+5+import multiprocessing
6+7+from typing import Any, Callable, ClassVar, Iterable, Optional, TypeVar
8+9+R = TypeVar('R')
10+S = TypeVar('S')
11+T = TypeVar('T')
12+A = TypeVar('A')
13+14+pool_processes: Optional[int] = None
15+16+# this thing is impossible to type because there's so much global state involved.
17+# wrapping in a class to get access to Generic[] parameters is not sufficient
18+# because mypy is too weak, and unnecessarily obscures how much global state is
19+# needed in each worker to make this whole brouhaha work.
20+_map_worker_fn: Any = None
21+_map_worker_state_fn: Any = None
22+_map_worker_state_arg: Any = None
23+24+def _map_worker_init(*args: Any) -> None:
25+ global _map_worker_fn, _map_worker_state_fn, _map_worker_state_arg
26+ (_map_worker_fn, _map_worker_state_fn, _map_worker_state_arg) = args
27+28+# NOTE: the state argument is never passed by any caller, we only use it as a localized
29+# cache for the created state in lieu of another global. it is effectively a global though.
30+def _map_worker_step(arg: Any, state: Any = []) -> Any:
31+ global _map_worker_fn, _map_worker_state_fn, _map_worker_state_arg
32+ # if a Pool initializer throws it'll just be retried, leading to endless loops.
33+ # doing the proper initialization only on first use avoids this.
34+ if not state:
35+ state.append(_map_worker_state_fn(_map_worker_state_arg))
36+ return _map_worker_fn(state[0], arg)
37+38+def map(fn: Callable[[S, T], R], d: Iterable[T], chunk_size: int,
39+ state_fn: Callable[[A], S], state_arg: A) -> list[R]:
40+ """
41+ `[ fn(state, i) for i in d ]` where `state = state_fn(state_arg)`, but using multiprocessing
42+ if `pool_processes` is not `None`. when using multiprocessing is used the state function will
43+ be run once in ever worker process and `multiprocessing.Pool.imap` will be used.
44+45+ **NOTE:** neither `state_fn` nor `fn` are allowed to mutate global state! doing so will cause
46+ discrepancies if `pool_processes` is not None, since each worker will have its own copy.
47+48+ **NOTE**: all data types that potentially cross a process boundary (so, all of them) must be
49+ pickle-able. this excludes lambdas, bound functions, local functions, and a number of other
50+ types depending on their exact internal structure. *theoretically* the pool constructor
51+ can transfer non-pickleable data to worker processes, but this only works when using the
52+ `fork` spawn method (and is thus not available on darwin or windows).
53+ """
54+ if pool_processes is None:
55+ state = state_fn(state_arg)
56+ return [ fn(state, i) for i in d ]
57+ with multiprocessing.Pool(pool_processes, _map_worker_init, (fn, state_fn, state_arg)) as p:
58+ return list(p.imap(_map_worker_step, d, chunk_size))
+3-3
pkgs/tools/security/grype/default.nix
···89buildGoModule rec {
10 pname = "grype";
11- version = "0.56.0";
1213 src = fetchFromGitHub {
14 owner = "anchore";
15 repo = pname;
16 rev = "v${version}";
17- hash = "sha256-xNv4pI6iT6lNmjeUIW8ObPFJw9H1SiVTg9fRx6Osiwc=";
18 # populate values that require us to use git. By doing this in postFetch we
19 # can delete .git afterwards and maintain better reproducibility of the src.
20 leaveDotGit = true;
···28 };
29 proxyVendor = true;
3031- vendorHash = "sha256-Sez5jNFdL11cHBBPcY0b8qUiupmjPo9MHwUUi7FaNiA=";
3233 nativeBuildInputs = [
34 installShellFiles
···89buildGoModule rec {
10 pname = "grype";
11+ version = "0.57.1";
1213 src = fetchFromGitHub {
14 owner = "anchore";
15 repo = pname;
16 rev = "v${version}";
17+ hash = "sha256-NACasOoCABoHmb4U5LvQ8EPO7G10A7uQtX4th/WJqrw=";
18 # populate values that require us to use git. By doing this in postFetch we
19 # can delete .git afterwards and maintain better reproducibility of the src.
20 leaveDotGit = true;
···28 };
29 proxyVendor = true;
3031+ vendorHash = "sha256-DLY0tcacGFcP17IqUVvpVkUjd2xQMO5JZxltmL4b+Wo=";
3233 nativeBuildInputs = [
34 installShellFiles