mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-06 04:53:27 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
77 lines
1.3 KiB
Nix
77 lines
1.3 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildPythonPackage,
|
|
fetchPypi,
|
|
pythonOlder,
|
|
rustPlatform,
|
|
cargo,
|
|
rustc,
|
|
setuptools,
|
|
setuptools-rust,
|
|
libiconv,
|
|
requests,
|
|
regex,
|
|
blobfile,
|
|
}:
|
|
let
|
|
pname = "tiktoken";
|
|
version = "0.7.0";
|
|
src = fetchPypi {
|
|
inherit pname version;
|
|
hash = "sha256-EHcmbpScJOApH2w1BDPG8JcTZezisXOiO8O5+d7+9rY=";
|
|
};
|
|
postPatch = ''
|
|
cp ${./Cargo.lock} Cargo.lock
|
|
'';
|
|
in
|
|
buildPythonPackage {
|
|
inherit
|
|
pname
|
|
version
|
|
src
|
|
postPatch
|
|
;
|
|
pyproject = true;
|
|
|
|
disabled = pythonOlder "3.8";
|
|
|
|
build-system = [
|
|
setuptools
|
|
setuptools-rust
|
|
];
|
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
inherit src postPatch;
|
|
name = "${pname}-${version}";
|
|
hash = "sha256-i0AQUu9ERDWBw0kjTTTyn4VHMig/k2/7wX2884MCGx8=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
rustPlatform.cargoSetupHook
|
|
setuptools-rust
|
|
cargo
|
|
rustc
|
|
];
|
|
|
|
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
|
|
|
|
dependencies = [
|
|
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 ];
|
|
};
|
|
}
|