at master 2.9 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 cmake, 7 opencv4, 8 ceres-solver, 9 suitesparse, 10 metis, 11 eigen, 12 setuptools, 13 pkg-config, 14 pybind11, 15 numpy, 16 pyyaml, 17 lapack, 18 gtest, 19 gflags, 20 glog, 21 pytestCheckHook, 22 networkx, 23 pillow, 24 exifread, 25 gpxpy, 26 pyproj, 27 python-dateutil, 28 joblib, 29 repoze-lru, 30 xmltodict, 31 distutils, 32 cloudpickle, 33 scipy, 34 sphinx, 35 matplotlib, 36 fpdf, 37}: 38 39buildPythonPackage rec { 40 pname = "opensfm"; 41 version = "unstable-2023-12-09"; 42 pyproject = true; 43 44 src = fetchFromGitHub { 45 owner = "mapillary"; 46 repo = "OpenSfM"; 47 rev = "7f170d0dc352340295ff480378e3ac37d0179f8e"; 48 sha256 = "sha256-l/HTVenC+L+GpMNnDgnSGZ7+Qd2j8b8cuTs3SmORqrg="; 49 }; 50 51 patches = [ 52 ./0002-cmake-find-system-distributed-gtest.patch 53 ./0003-cmake-use-system-pybind11.patch 54 ./0004-pybind_utils.h-conflicts-with-nixpkgs-pybind.patch 55 ./0005-fix-numpy-2-test-failures.patch # not upstreamed due to cla, but you're free upstream it -@pbsds 56 ./fix-scripts.patch 57 ]; 58 59 postPatch = '' 60 rm opensfm/src/cmake/FindGlog.cmake 61 rm opensfm/src/cmake/FindGflags.cmake 62 63 # HAHOG is the default descriptor. 64 # We'll test both HAHOG and SIFT because this is 65 # where segfaults might be introduced in future 66 echo 'feature_type: SIFT' >> data/berlin/config.yaml 67 echo 'feature_type: HAHOG' >> data/lund/config.yaml 68 69 # make opensfm correctly import glog headers 70 export CXXFLAGS=-DGLOG_USE_GLOG_EXPORT 71 72 sed -i -e 's/^.*BuildDoc.*$//' setup.py 73 ''; 74 75 build-system = [ setuptools ]; 76 77 nativeBuildInputs = [ 78 cmake 79 pkg-config 80 sphinx 81 ]; 82 83 buildInputs = [ 84 ceres-solver 85 suitesparse 86 metis 87 eigen 88 lapack 89 gflags 90 gtest 91 glog 92 pybind11 93 ]; 94 95 dependencies = [ 96 numpy 97 scipy 98 pyyaml 99 opencv4.cxxdev 100 networkx 101 pillow 102 matplotlib 103 fpdf 104 exifread 105 gpxpy 106 pyproj 107 python-dateutil 108 joblib 109 repoze-lru 110 xmltodict 111 cloudpickle 112 ]; 113 114 nativeCheckInputs = [ 115 pytestCheckHook 116 distutils 117 ]; 118 119 dontUseCmakeBuildDir = true; 120 cmakeFlags = [ 121 "-Bcmake_build" 122 "-Sopensfm/src" 123 ]; 124 125 disabledTests = [ 126 "test_run_all" # Matplotlib issues. Broken integration is less useless than a broken build 127 "test_match_candidates_from_metadata_bow" # flaky 128 ] 129 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 130 "test_reconstruction_incremental" 131 "test_reconstruction_triangulation" 132 ]; 133 134 pythonImportsCheck = [ "opensfm" ]; 135 136 meta = { 137 broken = stdenv.hostPlatform.isDarwin; 138 maintainers = [ 139 lib.maintainers.pbsds 140 lib.maintainers.SomeoneSerge 141 ]; 142 license = lib.licenses.bsd2; 143 changelog = "https://github.com/mapillary/OpenSfM/blob/${src.rev}/CHANGELOG.md"; 144 description = "Open source Structure-from-Motion pipeline from Mapillary"; 145 homepage = "https://opensfm.org/"; 146 }; 147}