at master 230 lines 6.5 kB view raw
1{ 2 lib, 3 cargo, 4 fetchFromGitHub, 5 installShellFiles, 6 pkg-config, 7 protobuf, 8 python3, 9 rustc, 10 rustPlatform, 11 versionCheckHook, 12 13 lspSupport ? true, 14}: 15 16let 17 python = python3.override { 18 packageOverrides = self: super: { 19 # https://github.com/Davidyz/VectorCode/pull/36 20 chromadb = super.chromadb.overridePythonAttrs (old: rec { 21 version = "0.6.3"; 22 src = fetchFromGitHub { 23 owner = "chroma-core"; 24 repo = "chroma"; 25 tag = version; 26 hash = "sha256-yvAX8buETsdPvMQmRK5+WFz4fVaGIdNlfhSadtHwU5U="; 27 }; 28 cargoDeps = rustPlatform.fetchCargoVendor { 29 pname = "chromadb"; 30 inherit version src; 31 hash = "sha256-lHRBXJa/OFNf4x7afEJw9XcuDveTBIy3XpQ3+19JXn4="; 32 }; 33 postPatch = null; 34 build-system = with self; [ 35 setuptools 36 setuptools-scm 37 ]; 38 nativeBuildInputs = [ 39 cargo 40 pkg-config 41 protobuf 42 rustc 43 rustPlatform.cargoSetupHook 44 ]; 45 dependencies = old.dependencies ++ [ 46 self.chroma-hnswlib 47 ]; 48 49 # The base package disables additional tests, so explicitly override 50 disabledTests = [ 51 # Tests are flaky / timing sensitive 52 "test_fastapi_server_token_authn_allows_when_it_should_allow" 53 "test_fastapi_server_token_authn_rejects_when_it_should_reject" 54 55 # Issue with event loop 56 "test_http_client_bw_compatibility" 57 58 # httpx ReadError 59 "test_not_existing_collection_delete" 60 ]; 61 62 disabledTestPaths = [ 63 # Tests require network access 64 "chromadb/test/auth/test_simple_rbac_authz.py" 65 "chromadb/test/db/test_system.py" 66 "chromadb/test/ef/test_default_ef.py" 67 "chromadb/test/property/" 68 "chromadb/test/property/test_cross_version_persist.py" 69 "chromadb/test/stress/" 70 "chromadb/test/test_api.py" 71 72 # httpx failures 73 "chromadb/test/api/test_delete_database.py" 74 75 # Cannot be loaded by pytest without path hacks (fixed in 1.0.0) 76 "chromadb/test/test_logservice.py" 77 "chromadb/test/proto/test_utils.py" 78 "chromadb/test/segment/distributed/test_protobuf_translation.py" 79 80 # Hypothesis FailedHealthCheck due to nested @given tests 81 "chromadb/test/cache/test_cache.py" 82 83 # Tests fail when running in parallel. 84 # E.g. when building the building python 3.12 and 3.13 versions simultaneously. 85 # ValueError: An instance of Chroma already exists for ephemeral with different settings 86 "chromadb/test/test_chroma.py" 87 "chromadb/test/test_client.py" 88 "chromadb/test/ef/test_multimodal_ef.py" 89 ]; 90 }); 91 }; 92 }; 93in 94python.pkgs.buildPythonApplication rec { 95 pname = "vectorcode"; 96 version = "0.7.15"; 97 pyproject = true; 98 99 src = fetchFromGitHub { 100 owner = "Davidyz"; 101 repo = "VectorCode"; 102 tag = version; 103 hash = "sha256-YRvJVdNZLmNongYEy06QPsmJkPvmg7cucjLJY05yD54="; 104 }; 105 106 build-system = with python.pkgs; [ 107 pdm-backend 108 ]; 109 110 pythonRelaxDeps = [ 111 "posthog" 112 "wheel" 113 ]; 114 dependencies = 115 with python.pkgs; 116 [ 117 chromadb 118 colorlog 119 httpx 120 json5 121 numpy 122 pathspec 123 psutil 124 pygments 125 python-dotenv 126 sentence-transformers 127 shtab 128 tabulate 129 transformers 130 tree-sitter 131 tree-sitter-language-pack 132 ] 133 ++ lib.optionals lspSupport optional-dependencies.lsp; 134 135 optional-dependencies = with python.pkgs; { 136 intel = [ 137 openvino 138 optimum 139 ]; 140 legacy = [ 141 numpy 142 torch 143 transformers 144 ]; 145 lsp = [ 146 lsprotocol 147 pygls 148 ]; 149 mcp = [ 150 mcp 151 pydantic 152 ]; 153 }; 154 155 nativeBuildInputs = [ 156 installShellFiles 157 ]; 158 159 postInstall = '' 160 $out/bin/vectorcode --print-completion=bash >vectorcode.bash 161 $out/bin/vectorcode --print-completion=zsh >vectorcode.zsh 162 installShellCompletion vectorcode.{bash,zsh} 163 ''; 164 165 makeWrapperArgs = [ 166 "--prefix" 167 "PYTHONPATH" 168 ":" 169 "$PYTHONPATH" 170 ]; 171 172 pythonImportsCheck = [ "vectorcode" ]; 173 174 nativeCheckInputs = [ 175 versionCheckHook 176 ] 177 ++ (with python.pkgs; [ 178 mcp 179 pygls 180 pytest-asyncio 181 pytestCheckHook 182 ]); 183 versionCheckProgramArg = "version"; 184 185 disabledTests = [ 186 # Require internet access 187 "test_chunked_add" 188 "test_chunked_add_empty_file" 189 "test_chunked_add_truncated" 190 "test_chunked_add_update_existing" 191 "test_chunked_add_with_existing" 192 "test_get_embedding_function" 193 "test_get_embedding_function_fallback" 194 "test_get_query_reranker_initialisation_error" 195 "test_get_query_result_chunks_with_query_exclude" 196 "test_get_query_result_files_include_chunk" 197 "test_get_query_result_files_multiple_queries" 198 "test_get_query_result_files_query_error" 199 "test_get_query_result_files_with_query_exclude" 200 "test_get_reranker" 201 "test_query_tool_success" 202 "test_supported_rerankers_initialization" 203 ]; 204 205 passthru = { 206 # Expose these overridden inputs for debugging 207 inherit python; 208 inherit (python.pkgs) chromadb; 209 }; 210 211 meta = { 212 description = "Code repository indexing tool to supercharge your LLM experience"; 213 homepage = "https://github.com/Davidyz/VectorCode"; 214 changelog = "https://github.com/Davidyz/VectorCode/releases/tag/${src.tag}"; 215 license = lib.licenses.mit; 216 maintainers = with lib.maintainers; [ GaetanLepage ]; 217 mainProgram = "vectorcode"; 218 badPlatforms = [ 219 # Error in cpuinfo: failed to parse the list of possible processors in /sys/devices/system/cpu/possible 220 # Error in cpuinfo: failed to parse the list of present processors in /sys/devices/system/cpu/present 221 # Error in cpuinfo: failed to parse both lists of possible and present processors 222 # terminate called after throwing an instance of 'onnxruntime::OnnxRuntimeException' 223 # what(): /build/source/include/onnxruntime/core/common/logging/logging.h:371 static const onnxruntime::logging::Logger& onnxruntime::logging::LoggingManager::DefaultLogger() Attempt to use DefaultLogger but none has been registered. 224 # 225 # Since 0.7.4, disabling `pythonImportsCheck` and `pytestCheckPhase` is not enough anymore. 226 # The error above happens at the end of `pypaInstallPhase`. 227 "aarch64-linux" 228 ]; 229 }; 230}