1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
cmake,
comic-neue,
boost,
catch2_3,
inchi,
cairo,
eigen,
python,
rapidjson,
maeparser,
coordgenlibs,
numpy,
pandas,
pillow,
memorymappingHook,
}:
let
external = {
avalon = fetchFromGitHub {
owner = "rdkit";
repo = "ava-formake";
rev = "AvalonToolkit_2.0.5-pre.3";
hash = "sha256-2MuFZgRIHXnkV7Nc1da4fa7wDx57VHUtwLthrmjk+5o=";
};
yaehmop = fetchFromGitHub {
owner = "greglandrum";
repo = "yaehmop";
rev = "v2023.03.1";
hash = "sha256-K9//cDN69U4sLETfIZq9NUaBE3RXOReH53qfiCzutqM=";
};
freesasa = fetchFromGitHub {
owner = "mittinatten";
repo = "freesasa";
rev = "2.0.3";
hash = "sha256-7E+imvfDAJFnXQRWb5hNaSu+Xrf9NXeIKc9fl+o3yHQ=";
};
};
in
buildPythonPackage rec {
pname = "rdkit";
version = "2023.09.5";
pyproject = false;
src =
let
versionTag = lib.replaceStrings [ "." ] [ "_" ] version;
in
fetchFromGitHub {
owner = pname;
repo = pname;
rev = "Release_${versionTag}";
hash = "sha256-ZYNAHNBHQPx8rBJSvEWFEpdSpYyXcoqJ+nBA7tpHwQs=";
};
unpackPhase = ''
cp -r $src/* .
find . -type d -exec chmod +w {} +
mkdir External/AvalonTools/avalon
# In buildPhase, CMake patches the file in this directory
# see https://github.com/rdkit/rdkit/pull/5928
cp -r ${external.avalon}/* External/AvalonTools/avalon
mkdir External/YAeHMOP/yaehmop
ln -s ${external.yaehmop}/* External/YAeHMOP/yaehmop
mkdir -p External/FreeSASA/freesasa
cp -r ${external.freesasa}/* External/FreeSASA/freesasa
chmod +w External/FreeSASA/freesasa/src
cp External/FreeSASA/freesasa2.c External/FreeSASA/freesasa/src
ln -s ${rapidjson} External/rapidjson-1.1.0
ln -s ${comic-neue}/share/fonts/truetype/ComicNeue-Regular.ttf Data/Fonts/
'';
nativeBuildInputs = [ cmake ];
buildInputs = [
boost
cairo
catch2_3
] ++ lib.optionals (stdenv.system == "x86_64-darwin") [ memorymappingHook ];
propagatedBuildInputs = [
numpy
pandas
pillow
];
hardeningDisable = [ "format" ]; # required by yaehmop
dontUseSetuptoolsBuild = true;
dontUsePipInstall = true;
dontUseSetuptoolsCheck = true;
preConfigure = ''
# Since we can't expand with bash in cmakeFlags
appendToVar cmakeFlags "-DPYTHON_NUMPY_INCLUDE_PATH=$(${python}/bin/python -c 'import numpy; print(numpy.get_include())')"
appendToVar cmakeFlags "-DFREESASA_DIR=$PWD/External/FreeSASA/freesasa"
appendToVar cmakeFlags "-DFREESASA_SRC_DIR=$PWD/External/FreeSASA/freesasa"
appendToVar cmakeFlags "-DAVALONTOOLS_DIR=$PWD/External/AvalonTools/avalon"
'';
cmakeFlags = [
"-DINCHI_LIBRARY=${inchi}/lib/libinchi.so"
"-DINCHI_LIBRARIES=${inchi}/lib/libinchi.so"
"-DINCHI_INCLUDE_DIR=${inchi}/include/inchi"
"-DEIGEN3_INCLUDE_DIR=${eigen}/include/eigen3"
"-DRDK_INSTALL_INTREE=OFF"
"-DRDK_INSTALL_STATIC_LIBS=OFF"
"-DRDK_BUILD_INCHI_SUPPORT=ON"
"-DRDK_BUILD_AVALON_SUPPORT=ON"
"-DRDK_BUILD_FREESASA_SUPPORT=ON"
"-DRDK_BUILD_YAEHMOP_SUPPORT=ON"
"-DRDK_BUILD_MAEPARSER_SUPPORT=ON"
"-DMAEPARSER_DIR=${maeparser}"
"-DRDK_BUILD_COORDGEN_SUPPORT=ON"
"-DCOORDGEN_DIR=${coordgenlibs}"
"-DRDK_USE_URF=OFF"
"-DRDK_USE_FLEXBISON=OFF"
"-DRDK_BUILD_CAIRO_SUPPORT=ON"
"-DRDK_BUILD_THREADSAFE_SSS=ON"
"-DRDK_TEST_MULTITHREADED=ON"
"-DRDK_BUILD_CPP_TESTS=ON"
"-DRDK_TEST_MULTITHREADED=ON"
"-DPYTHON_EXECUTABLE=${python}/bin/python"
"-DBOOST_ROOT=${boost}"
"-DBoost_NO_SYSTEM_PATHS=ON"
"-DBoost_NO_BOOST_CMAKE=TRUE"
"-DCMAKE_SKIP_BUILD_RPATH=ON" # fails to find libs in pythonImportsCheckPhase otherwise
];
checkPhase = ''
export QT_QPA_PLATFORM='offscreen'
export RDBASE=$(realpath ..)
export PYTHONPATH="$out/${python.sitePackages}:$PYTHONPATH"
(cd $RDBASE/rdkit/Chem && python $RDBASE/rdkit/TestRunner.py test_list.py)
'';
pythonImportsCheck = [
"rdkit"
"rdkit.Chem"
"rdkit.Chem.AllChem"
];
meta = with lib; {
description = "Open source toolkit for cheminformatics";
maintainers = with maintainers; [
rmcgibbo
natsukium
];
license = licenses.bsd3;
homepage = "https://www.rdkit.org";
changelog = "https://github.com/rdkit/rdkit/releases/tag/${src.rev}";
};
}
|