python3Packages.tokenizers: switch to buildPythonPackage

Use the new cargoSetupHook to set up Cargo vendoring, so that we do
not need buildRustPackage anymore.
This commit is contained in:
Daniël de Kok 2021-02-09 11:41:01 +01:00
parent d083f412fa
commit 4a4da22674

View File

@ -1,12 +1,10 @@
{ lib { lib
, rustPlatform
, fetchFromGitHub , fetchFromGitHub
, fetchurl , fetchurl
, pipInstallHook , buildPythonPackage
, rustPlatform
, setuptools-rust , setuptools-rust
, wheel
, numpy , numpy
, python
, datasets , datasets
, pytestCheckHook , pytestCheckHook
, requests , requests
@ -49,7 +47,7 @@ let
url = "https://s3.amazonaws.com/models.huggingface.co/bert/openai-gpt-merges.txt"; url = "https://s3.amazonaws.com/models.huggingface.co/bert/openai-gpt-merges.txt";
sha256 = "09a754pm4djjglv3x5pkgwd6f79i2rq8ydg0f7c3q1wmwqdbba8f"; sha256 = "09a754pm4djjglv3x5pkgwd6f79i2rq8ydg0f7c3q1wmwqdbba8f";
}; };
in rustPlatform.buildRustPackage rec { in buildPythonPackage rec {
pname = "tokenizers"; pname = "tokenizers";
version = "0.10.0"; version = "0.10.0";
@ -60,19 +58,22 @@ in rustPlatform.buildRustPackage rec {
hash = "sha256-rQ2hRV52naEf6PvRsWVCTN7B1oXAQGmnpJw4iIdhamw="; hash = "sha256-rQ2hRV52naEf6PvRsWVCTN7B1oXAQGmnpJw4iIdhamw=";
}; };
cargoSha256 = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0="; cargoDeps = rustPlatform.fetchCargoTarball {
inherit src sourceRoot;
name = "${pname}-${version}";
hash = "sha256-BoHIN/519Top1NUBjpB/oEMqi86Omt3zTQcXFWqrek0=";
};
sourceRoot = "source/bindings/python"; sourceRoot = "source/bindings/python";
nativeBuildInputs = [ nativeBuildInputs = [ setuptools-rust ] ++ (with rustPlatform; [
pipInstallHook cargoSetupHook
setuptools-rust rust.cargo
wheel rust.rustc
]; ]);
propagatedBuildInputs = [ propagatedBuildInputs = [
numpy numpy
python
]; ];
installCheckInputs = [ installCheckInputs = [
@ -99,14 +100,6 @@ in rustPlatform.buildRustPackage rec {
ln -s ${openaiMerges} openai-gpt-merges.txt ) ln -s ${openaiMerges} openai-gpt-merges.txt )
''; '';
buildPhase = ''
${python.interpreter} setup.py bdist_wheel
'';
installPhase = ''
pipInstallPhase
'';
preCheck = '' preCheck = ''
HOME=$TMPDIR HOME=$TMPDIR
''; '';