|
| 1 | +# Copyright 2023-2026 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +# Autogenerated by pycargoebuild 0.15.0 |
| 5 | + |
| 6 | +EAPI=8 |
| 7 | + |
| 8 | +DISTUTILS_USE_PEP517=maturin |
| 9 | +PYTHON_COMPAT=( python3_{12..14} ) |
| 10 | +DISTUTILS_EXT=1 |
| 11 | +RUST_MIN_VER="1.87.0" |
| 12 | + |
| 13 | +CRATES=" |
| 14 | +" |
| 15 | + |
| 16 | +inherit cargo distutils-r1 |
| 17 | + |
| 18 | +DESCRIPTION="Implementation of today's most used tokenizers" |
| 19 | +HOMEPAGE="https://github.com/huggingface/tokenizers" |
| 20 | +SRC_URI=" |
| 21 | + https://github.com/huggingface/${PN}/archive/refs/tags/v${PV}.tar.gz |
| 22 | + -> ${P}.gh.tar.gz |
| 23 | + ${CARGO_CRATE_URIS} |
| 24 | +" |
| 25 | +if [[ ${PKGBUMPING} != ${PVR} ]]; then |
| 26 | + SRC_URI+=" |
| 27 | + https://dev.gentoo.org/~tupone/distfiles/${P}-crates.tar.xz |
| 28 | + https://dev.gentoo.org/~tupone/distfiles/${PN}-python-${PV}-crates.tar.xz |
| 29 | + " |
| 30 | +fi |
| 31 | + |
| 32 | +LICENSE="Apache-2.0" |
| 33 | +# Dependent crate licenses |
| 34 | +LICENSE+=" |
| 35 | + Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD ISC MIT MPL-2.0 |
| 36 | + Unicode-DFS-2016 |
| 37 | +" |
| 38 | +SLOT="0" |
| 39 | +KEYWORDS="~amd64" |
| 40 | + |
| 41 | +RDEPEND="dev-libs/oniguruma" |
| 42 | +BDEPEND=" |
| 43 | + dev-python/setuptools-rust[${PYTHON_USEDEP}] |
| 44 | +" |
| 45 | + |
| 46 | +EPYTEST_PLUGINS=( ) |
| 47 | +distutils_enable_tests pytest |
| 48 | + |
| 49 | +QA_FLAGS_IGNORED=".*/site-packages/tokenizers/.*so" |
| 50 | + |
| 51 | +src_unpack() { |
| 52 | + cargo_src_unpack |
| 53 | +} |
| 54 | + |
| 55 | +pkg_setup() { |
| 56 | + rust_pkg_setup |
| 57 | +} |
| 58 | + |
| 59 | +src_prepare() { |
| 60 | + default |
| 61 | + cd bindings/python || die |
| 62 | + eapply "${FILESDIR}"/${PN}-0.21.2-test.patch |
| 63 | + distutils-r1_src_prepare |
| 64 | +} |
| 65 | + |
| 66 | +src_configure() { |
| 67 | + cd "${S}/tokenizers" || die |
| 68 | + cargo_src_configure |
| 69 | + cd "${S}/bindings/python" || die |
| 70 | + distutils-r1_src_configure |
| 71 | +} |
| 72 | + |
| 73 | +src_compile() { |
| 74 | + export RUSTONIG_SYSTEM_LIBONIG=1 |
| 75 | + cd "${S}/tokenizers" || die |
| 76 | + cargo_src_compile |
| 77 | + cd "${S}/bindings/python" || die |
| 78 | + distutils-r1_src_compile |
| 79 | +} |
| 80 | + |
| 81 | +src_test() { |
| 82 | + cd "${S}/tokenizers" || die |
| 83 | + # Tests do not work |
| 84 | + #cargo_src_test |
| 85 | + cd "${S}/bindings/python" || die |
| 86 | + local -x EPYTEST_IGNORE=( benches/test_tiktoken.py ) |
| 87 | + local -x EPYTEST_DESELECT=( |
| 88 | + tests/bindings/test_encoding.py::TestEncoding::test_char_to_token |
| 89 | + tests/bindings/test_encoding.py::TestEncoding::test_char_to_word |
| 90 | + tests/bindings/test_encoding.py::TestEncoding::test_invalid_truncate_direction |
| 91 | + tests/bindings/test_encoding.py::TestEncoding::test_n_sequences |
| 92 | + tests/bindings/test_encoding.py::TestEncoding::test_sequence_ids |
| 93 | + tests/bindings/test_encoding.py::TestEncoding::test_token_to_chars |
| 94 | + tests/bindings/test_encoding.py::TestEncoding::test_token_to_sequence |
| 95 | + tests/bindings/test_encoding.py::TestEncoding::test_token_to_word |
| 96 | + tests/bindings/test_encoding.py::TestEncoding::test_truncation |
| 97 | + tests/bindings/test_encoding.py::TestEncoding::test_word_to_chars |
| 98 | + tests/bindings/test_encoding.py::TestEncoding::test_word_to_tokens |
| 99 | + tests/bindings/test_models.py::TestWordLevel::test_instantiate |
| 100 | + tests/bindings/test_models.py::TestWordPiece::test_instantiate |
| 101 | + tests/bindings/test_processors.py::TestByteLevelProcessing::test_processing |
| 102 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_async_methods_existence |
| 103 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_basic_encoding |
| 104 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_concurrency |
| 105 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_decode |
| 106 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_encode |
| 107 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_error_handling |
| 108 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_large_batch |
| 109 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_numpy_inputs |
| 110 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_various_input_formats |
| 111 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_performance_comparison |
| 112 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_with_special_tokens |
| 113 | + tests/bindings/test_tokenizer.py::TestAsyncTokenizer::test_with_truncation_padding |
| 114 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_encode_add_special_tokens |
| 115 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_encode_formats |
| 116 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_encode_special_tokens |
| 117 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_decode_skip_special_tokens |
| 118 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_decode_stream_fallback |
| 119 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_from_pretrained |
| 120 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_from_pretrained_revision |
| 121 | + tests/bindings/test_tokenizer.py::TestTokenizer::test_splitting |
| 122 | + tests/bindings/test_trainers.py::TestUnigram::test_continuing_prefix_trainer_mismatch |
| 123 | + tests/bindings/test_trainers.py::TestUnigram::test_train |
| 124 | + tests/bindings/test_trainers.py::TestUnigram::test_train_parallelism_with_custom_pretokenizer |
| 125 | + tests/documentation/test_pipeline.py::TestPipeline::test_bert_example |
| 126 | + tests/documentation/test_pipeline.py::TestPipeline::test_pipeline |
| 127 | + tests/documentation/test_quicktour.py::TestQuicktour::test_quicktour |
| 128 | + tests/documentation/test_tutorial_train_from_iterators.py::TestTrainFromIterators::test_datasets |
| 129 | + tests/documentation/test_tutorial_train_from_iterators.py::TestTrainFromIterators::test_gzip |
| 130 | + tests/implementations/test_byte_level_bpe.py::TestByteLevelBPE::test_add_prefix_space |
| 131 | + tests/implementations/test_byte_level_bpe.py::TestByteLevelBPE::test_basic_encode |
| 132 | + tests/implementations/test_byte_level_bpe.py::TestByteLevelBPE::test_lowerspace |
| 133 | + tests/implementations/test_byte_level_bpe.py::TestByteLevelBPE::test_multiprocessing_with_parallelism |
| 134 | + tests/implementations/test_bert_wordpiece.py::TestBertWordPieceTokenizer::test_basic_encode |
| 135 | + tests/implementations/test_bert_wordpiece.py::TestBertWordPieceTokenizer::test_multiprocessing_with_parallelism |
| 136 | + tests/implementations/test_char_bpe.py::TestCharBPETokenizer::test_basic_encode |
| 137 | + tests/implementations/test_char_bpe.py::TestCharBPETokenizer::test_decoding |
| 138 | + tests/implementations/test_char_bpe.py::TestCharBPETokenizer::test_lowercase |
| 139 | + tests/implementations/test_char_bpe.py::TestCharBPETokenizer::test_multiprocessing_with_parallelism |
| 140 | + tests/test_serialization.py::TestSerialization::test_full_serialization_albert |
| 141 | + tests/test_serialization.py::TestSerialization::test_str_big |
| 142 | + ) |
| 143 | + distutils-r1_src_test |
| 144 | +} |
| 145 | + |
| 146 | +src_install() { |
| 147 | + cd "${S}/bindings/python" || die |
| 148 | + distutils-r1_src_install |
| 149 | +} |
0 commit comments