depot/third_party/nixpkgs/pkgs/development/python-modules/pylance/default.nix
Default email 472aeafc57 Project import generated by Copybara.
GitOrigin-RevId: c31898adf5a8ed202ce5bea9f347b1c6871f32d1
2024-10-04 18:56:33 +02:00

137 lines
2.8 KiB
Nix

{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
rustPlatform,
# nativeBuildInputs
pkg-config,
# buildInputs
libiconv,
protobuf,
darwin,
# dependencies
numpy,
pyarrow,
# optional-dependencies
torch,
# tests
duckdb,
ml-dtypes,
pandas,
pillow,
polars,
pytestCheckHook,
tqdm,
# passthru
nix-update-script,
}:
buildPythonPackage rec {
pname = "pylance";
version = "0.17.0";
pyproject = true;
src = fetchFromGitHub {
owner = "lancedb";
repo = "lance";
rev = "refs/tags/v${version}";
hash = "sha256-E+29CbVNbzmrQnBZt0860IvL4xYZqzE+uzSuKDwgxzg=";
};
buildAndTestSubdir = "python";
cargoDeps = rustPlatform.importCargoLock { lockFile = ./Cargo.lock; };
postPatch = ''
ln -s ${./Cargo.lock} Cargo.lock
'';
nativeBuildInputs = [
pkg-config
rustPlatform.cargoSetupHook
];
build-system = [ rustPlatform.maturinBuildHook ];
buildInputs =
[
libiconv
protobuf
]
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
Security
SystemConfiguration
]
);
pythonRelaxDeps = [ "pyarrow" ];
dependencies = [
numpy
pyarrow
];
optional-dependencies = {
torch = [ torch ];
};
pythonImportsCheck = [ "lance" ];
nativeCheckInputs = [
duckdb
ml-dtypes
pandas
pillow
polars
pytestCheckHook
tqdm
] ++ optional-dependencies.torch;
preCheck = ''
cd python/python/tests
'';
disabledTests =
lib.optionals stdenv.hostPlatform.isDarwin [
# AttributeError: module 'torch.distributed' has no attribute 'is_initialized'
"test_convert_int_tensors"
"test_ground_truth"
"test_index_cast_centroids"
"test_index_with_no_centroid_movement"
"test_iter_filter"
"test_iter_over_dataset_fixed_shape_tensor"
"test_iter_over_dataset_fixed_size_lists"
]
++ [
# incompatible with duckdb 1.1.1
"test_duckdb_pushdown_extension_types"
];
passthru.updateScript = nix-update-script {
extraArgs = [
"--generate-lockfile"
"--lockfile-metadata-path"
"python"
];
};
meta = {
description = "Python wrapper for Lance columnar format";
homepage = "https://github.com/lancedb/lance";
changelog = "https://github.com/lancedb/lance/releases/tag/v${version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ natsukium ];
# test_indices.py ...sss.Fatal Python error: Fatal Python error: Illegal instructionIllegal instruction
# File "/nix/store/wiiccrs0vd1qbh4j6ki9p40xmamsjix3-python3.12-pylance-0.17.0/lib/python3.12/site-packages/lance/indices.py", line 237 in train_ivf
broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64;
};
}