depot/third_party/nixpkgs/pkgs/development/python-modules/tiktoken/default.nix
Default email 2c76a4cb41 Project import generated by Copybara.
GitOrigin-RevId: c757e9bd77b16ca2e03c89bf8bc9ecb28e0c06ad
2023-11-16 04:20:00 +00:00

74 lines
1.3 KiB
Nix

{ lib
, stdenv
, buildPythonPackage
, fetchPypi
, pythonOlder
, rustPlatform
, cargo
, rustc
, setuptools
, setuptools-rust
, wheel
, libiconv
, requests
, regex
, blobfile
}:
let
pname = "tiktoken";
version = "0.5.1";
src = fetchPypi {
inherit pname version;
hash = "sha256-J+dzVkIyAE9PgQ/R+FI2Zz7DpW7X8SBvye2GcOvtuXo=";
};
postPatch = ''
cp ${./Cargo.lock} Cargo.lock
'';
in
buildPythonPackage {
inherit pname version src postPatch;
format = "pyproject";
disabled = pythonOlder "3.8";
nativeBuildInput = [
setuptools
setuptools-rust
wheel
];
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src postPatch;
name = "${pname}-${version}";
hash = "sha256-Q7XO+auj4tKDAGbqNn9pmJg8EJvooN2ie0lWwZVrld4=";
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
setuptools-rust
cargo
rustc
];
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
propagatedBuildInputs = [
requests
regex
blobfile
];
# almost all tests require network access
doCheck = false;
pythonImportsCheck = [
"tiktoken"
];
meta = with lib; {
description = "tiktoken is a fast BPE tokeniser for use with OpenAI's models.";
homepage = "https://github.com/openai/tiktoken";
license = licenses.mit;
maintainers = with maintainers; [ happysalada ];
};
}