1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5
6 # dependencies
7 botan3,
8
9 # build dependencies
10 setuptools,
11 setuptools-scm,
12}:
13
14buildPythonPackage rec {
15 pname = "botan3";
16
17 inherit (botan3) src version;
18
19 pyproject = true;
20
21 build-system = [
22 setuptools
23 setuptools-scm
24 ];
25
26 # not necessary for build, but makes it easier to discover for
27 # SBOM tooling
28 buildInputs = [ botan3 ];
29
30 # not necessary for build, but makes it easier to discover for
31 # SBOM tooling
32 nativeBuildInputs = [
33 setuptools
34 setuptools-scm
35 ];
36
37 sourceRoot = "Botan-${version}/src/python";
38
39 postPatch = ''
40 # remove again, when https://github.com/randombit/botan/pull/5040 got
41 # merged
42 cp ${./pyproject.toml} pyproject.toml
43 ''
44 + (
45 if stdenv.hostPlatform.isDarwin then
46 ''
47 botanLibPath=$(find ${lib.getLib botan3}/lib -name 'libbotan-3.dylib' -print -quit)
48 substituteInPlace botan3.py --replace-fail 'libbotan-3.dylib' "$botanLibPath"
49 ''
50 else if stdenv.hostPlatform.isMinGW then
51 ''
52 botanLibPath=$(find ${lib.getLib botan3}/lib -name 'libbotan-3.dll' -print -quit)
53 substituteInPlace botan3.py --replace-fail 'libbotan-3.dll' "$botanLibPath"
54 ''
55 # Linux/other Unix-like system
56 else
57 ''
58 botanLibPath=$(find ${lib.getLib botan3}/lib -name 'libbotan-3.so' -print -quit)
59 substituteInPlace botan3.py --replace-fail 'libbotan-3.so' "$botanLibPath"
60 ''
61 );
62
63 pythonImportsCheck = [ "botan3" ];
64
65 meta = {
66 description = "Python Bindings for botan3 cryptography library";
67 homepage = "https://github.com/randombit/botan";
68 changelog = "https://github.com/randombit/botan/blob/${version}/news.rst";
69 license = lib.licenses.bsd2;
70 maintainers = with lib.maintainers; [ thillux ];
71 };
72}