@@ -0,0 +1,122 @@
1+{ lib
2+, fetchPypi
3+, buildPythonPackage
4+, isPy3k
5+, markupsafe
6+, click
7+, typecode
8+, gemfileparser
9+, pefile
10+, fingerprints
11+, spdx-tools
12+, fasteners
13+, pycryptodome
14+, urlpy
15+, dparse
16+, jaraco_functools
17+, pkginfo
18+, debian-inspector
19+, extractcode
20+, ftfy
21+, pyahocorasick
22+, colorama
23+, jsonstreams
24+, packageurl-python
25+, pymaven-patch
26+, nltk
27+, pygments
28+, bitarray
29+, jinja2
30+, javaproperties
31+, boolean-py
32+, license-expression
33+, extractcode-7z
34+, extractcode-libarchive
35+, typecode-libmagic
36+, pytestCheckHook
37+}:
38+buildPythonPackage rec {
39+ pname = "scancode-toolkit";
40+ version = "21.3.31";
41+ disabled = !isPy3k;
42+
43+ src = fetchPypi {
44+ inherit pname version;
45+ sha256 = "7e0301031a302dedbb4304a91249534f3d036f84a119170b8a9fe70bd57cff95";
46+ };
47+
48+ dontConfigure = true;
49+
50+ # https://github.com/nexB/scancode-toolkit/issues/2501
51+ # * dparse2 is a "Temp fork for Python 2 support", but pdfminer requires
52+ # Python 3, so it's "fine" to leave dparse2 unpackaged and use the "normal"
53+ # version
54+ # * ftfy was pinned for similar reasons (to support Python 2), but rather than
55+ # packaging an older version, I figured it would be better to remove the
56+ # erroneous (at least for our usage) version bound
57+ # * bitarray's version bound appears to be unnecessary for similar reasons
58+ postPatch = ''
59+ substituteInPlace setup.cfg \
60+ --replace "dparse2" "dparse" \
61+ --replace "ftfy < 5.0.0" "ftfy" \
62+ --replace "bitarray >= 0.8.1, < 1.0.0" "bitarray"
63+ '';
64+
65+ propagatedBuildInputs = [
66+ markupsafe
67+ click
68+ typecode
69+ gemfileparser
70+ pefile
71+ fingerprints
72+ spdx-tools
73+ fasteners
74+ pycryptodome
75+ urlpy
76+ dparse
77+ jaraco_functools
78+ pkginfo
79+ debian-inspector
80+ extractcode
81+ ftfy
82+ pyahocorasick
83+ colorama
84+ jsonstreams
85+ packageurl-python
86+ pymaven-patch
87+ nltk
88+ pygments
89+ bitarray
90+ jinja2
91+ javaproperties
92+ boolean-py
93+ license-expression
94+ extractcode-7z
95+ extractcode-libarchive
96+ typecode-libmagic
97+ ];
98+
99+ checkInputs = [
100+ pytestCheckHook
101+ ];
102+
103+ # Importing scancode needs a writeable home, and preCheck happens in between
104+ # pythonImportsCheckPhase and pytestCheckPhase.
105+ postInstall = ''
106+ export HOME=$(mktemp -d)
107+ '';
108+
109+ pythonImportsCheck = [
110+ "scancode"
111+ ];
112+
113+ # takes a long time and doesn't appear to do anything
114+ dontStrip = true;
115+
116+ meta = with lib; {
117+ description = "A tool to scan code for license, copyright, package and their documented dependencies and other interesting facts";
118+ homepage = "https://github.com/nexB/scancode-toolkit";
119+ license = with licenses; [ asl20 cc-by-40 ];
120+ maintainers = teams.determinatesystems.members;
121+ };
122+}