anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / applications / science / chemistry / pymol / default.nix
blob295ac7e14cb232d41e35df1cbcdfa8050c948e7c
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , makeDesktopItem
5 , python3Packages
6 , netcdf
7 , glew
8 , glm
9 , libpng
10 , libxml2
11 , freetype
12 , msgpack
13 , qt5
15 let
16   pname = "pymol";
17   description = "A Python-enhanced molecular graphics tool";
19   desktopItem = makeDesktopItem {
20     name = pname;
21     exec = pname;
22     desktopName = "PyMol Molecular Graphics System";
23     genericName = "Molecular Modeler";
24     comment = description;
25     icon = pname;
26     mimeTypes = [
27       "chemical/x-pdb"
28       "chemical/x-mdl-molfile"
29       "chemical/x-mol2"
30       "chemical/seq-aa-fasta"
31       "chemical/seq-na-fasta"
32       "chemical/x-xyz"
33       "chemical/x-mdl-sdf"
34     ];
35     categories = [ "Graphics" "Education" "Science" "Chemistry" ];
36   };
38 python3Packages.buildPythonApplication rec {
39   inherit pname;
40   version = "3.0.0";
41   pyproject = true;
43   src = fetchFromGitHub {
44     owner = "schrodinger";
45     repo = "pymol-open-source";
46     rev = "v${version}";
47     hash = "sha256-GhTHxacjGN7XklZ6gileBMRZAGq4Pp4JknNL+qGqrVE=";
48   };
50   postPatch = ''
51     substituteInPlace setup.py \
52       --replace-fail "self.install_libbase" '"${placeholder "out"}/${python3Packages.python.sitePackages}"'
53   '';
55   build-system = [
56     python3Packages.setuptools
57   ];
59   nativeBuildInputs = [ qt5.wrapQtAppsHook ];
60   buildInputs = [ python3Packages.numpy python3Packages.pyqt5 glew glm libpng libxml2 freetype msgpack netcdf ];
61   env.NIX_CFLAGS_COMPILE = "-I ${libxml2.dev}/include/libxml2";
63   postInstall = with python3Packages; ''
64     wrapProgram $out/bin/pymol \
65       --prefix PYTHONPATH : ${lib.makeSearchPathOutput "lib" python3Packages.python.sitePackages [ pyqt5 pyqt5.pyqt5-sip ]}
67     mkdir -p "$out/share/icons/"
68     ln -s $out/${python3Packages.python.sitePackages}/pymol/pymol_path/data/pymol/icons/icon2.svg "$out/share/icons/pymol.svg"
69   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
70     cp -r "${desktopItem}/share/applications/" "$out/share/"
71   '';
73   pythonImportsCheck = [
74     "pymol"
75   ];
77   nativeCheckInputs = with python3Packages; [
78     python3Packages.msgpack
79     pillow
80     pytestCheckHook
81   ];
83   # some tests hang for some reason
84   doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
86   disabledTestPaths = [
87     # require biopython which is broken as of 2024-04-20
88     "tests/api/seqalign.py"
89   ];
91   disabledTests = [
92     # the output image does not exactly match
93     "test_commands"
94     # touch the network
95     "testFetch"
96     # requires collada2gltf which is not included in nixpkgs
97     "testglTF"
98     # require mmtf-cpp which does not support darwin
99     "testMMTF"
100     "testSave_symmetry__mmtf"
101   ];
103   preCheck = ''
104     cd testing
105   '';
107   __darwinAllowLocalNetworking = true;
109   preFixup = ''
110     wrapQtApp "$out/bin/pymol"
111   '';
113   meta = with lib; {
114     inherit description;
115     mainProgram = "pymol";
116     homepage = "https://www.pymol.org/";
117     license = licenses.mit;
118     maintainers = with maintainers; [ natsukium samlich ];
119   };