# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
addr2line@0.24.2
adler2@2.0.0
ahash@0.8.11
aho-corasick@1.1.3
allocative@0.3.4
allocative_derive@0.3.3
allocator-api2@0.2.21
android_system_properties@0.1.5
android-tzdata@0.1.1
anstream@0.6.19
anstyle@1.0.11
anstyle-parse@0.2.0
anstyle-query@1.0.0
anstyle-wincon@3.0.7
anyhow@1.0.98
append-only-vec@0.1.2
argfile@0.2.1
arrayref@0.3.6
arrayvec@0.7.6
atomic@0.5.1
attribute-derive@0.10.3
attribute-derive-macro@0.10.3
autocfg@1.1.0
backtrace@0.3.75
base64@0.22.1
bitflags@1.3.2
bitflags@2.9.0
blake3@1.8.2
block-buffer@0.10.2
bstr@1.12.0
bumpalo@3.16.0
byteorder@1.5.0
bytes@1.10.1
castaway@0.2.3
cc@1.2.10
cfg-if@1.0.1
chrono@0.4.41
clap@4.5.42
clap_builder@4.5.42
clap_derive@4.5.41
clap_lex@0.7.4
codespan-reporting@0.12.0
collection_literals@1.0.2
colorchoice@1.0.0
compact_str@0.8.0
compact_str@0.9.0
configparser@3.1.0
console@0.15.7
constant_time_eq@0.3.1
const-str@0.4.3
convert_case@0.6.0
core-foundation-sys@0.8.7
crossbeam-channel@0.5.15
crossbeam-deque@0.8.6
crossbeam-epoch@0.9.18
crossbeam-utils@0.8.21
crypto-common@0.1.6
ctor@0.1.26
cxxbridge-cmd@1.0.160
cxxbridge-flags@1.0.160
cxxbridge-macro@1.0.160
darling@0.20.10
darling_core@0.20.10
darling_macro@0.20.10
dashmap@5.5.3
deranged@0.4.1
derivative@2.2.0
derive-where@1.5.0
diff@0.1.12
digest@0.10.7
dupe@0.9.1
dupe_derive@0.9.1
either@1.15.0
encode_unicode@0.3.6
enum-iterator@2.1.0
enum-iterator-derive@1.4.0
env_logger@0.8.4
equivalent@1.0.0
errno@0.3.10
fastrand@2.3.0
filetime@0.2.25
fnv@1.0.7
foldhash@0.1.5
form_urlencoded@1.2.1
fs-err@2.11.0
fsevent-sys@4.0.0
futures@0.1.31
futures@0.3.31
futures-channel@0.3.31
futures-core@0.3.31
futures-executor@0.3.31
futures-io@0.3.31
futures-macro@0.3.31
futures-sink@0.3.31
futures-task@0.3.31
futures-util@0.3.31
fuzzy-matcher@0.3.7
fxhash@0.2.1
generic-array@0.14.7
getopts@0.2.21
getrandom@0.2.16
getrandom@0.3.3
get-size2@0.5.1
get-size-derive2@0.5.1
gimli@0.31.1
glob@0.3.2
globset@0.4.15
hashbrown@0.12.3
hashbrown@0.14.5
hashbrown@0.15.2
heck@0.5.0
hermit-abi@0.3.9
hex@0.4.3
home@0.5.11
human_bytes@0.4.3
iana-time-zone@0.1.53
iana-time-zone-haiku@0.1.1
icu_collections@1.5.0
icu_locid@1.5.0
icu_locid_transform@1.5.0
icu_locid_transform_data@1.5.0
icu_normalizer@1.5.0
icu_normalizer_data@1.5.0
icu_properties@1.5.1
icu_properties_data@1.5.0
icu_provider@1.5.0
icu_provider_macros@1.5.0
ident_case@1.0.1
idna@1.0.3
idna_adapter@1.2.0
ignore@0.4.23
indexmap@1.9.2
indexmap@2.10.0
indicatif@0.17.9
Inflector@0.11.4
inotify@0.9.2
inotify-sys@0.1.3
instant@0.1.12
interpolator@0.5.0
io-uring@0.7.9
is-macro@0.3.6
is_terminal_polyfill@1.70.1
itertools@0.10.5
itertools@0.11.0
itertools@0.14.0
itoa@0.4.8
itoa@1.0.14
jobserver@0.1.33
js-sys@0.3.77
kqueue@1.0.4
kqueue-sys@1.0.3
lazy_static@1.5.0
libc@0.2.174
libmimalloc-sys@0.1.42
libredox@0.1.3
link-cplusplus@1.0.9
linux-raw-sys@0.4.15
linux-raw-sys@0.9.4
litemap@0.7.3
lock_api@0.4.13
lock_free_hashtable@0.1.1
log@0.4.27
lsp-server@0.7.2
lsp-types@0.94.1
manyhow@0.11.4
manyhow-macros@0.11.4
maplit@1.0.2
matchers@0.2.0
memchr@2.7.5
memmap2@0.9.5
memory-stats@1.2.0
mimalloc@0.1.46
miniz_oxide@0.8.8
mio@0.8.11
mio@1.0.2
notify@5.0.0
nu-ansi-term@0.50.1
number_prefix@0.4.0
num-bigint@0.4.6
num-conv@0.1.0
num-integer@0.1.46
num_threads@0.1.3
num-traits@0.2.19
object@0.36.7
once_cell@1.21.3
os_str_bytes@7.1.1
parking_lot@0.11.2
parking_lot@0.12.3
parking_lot_core@0.8.5
parking_lot_core@0.9.9
parse-display@0.8.2
parse-display-derive@0.8.2
paste@1.0.15
path-absolutize@3.1.0
path-dedot@3.1.0
pathdiff@0.2.3
percent-encoding@2.3.1
phf@0.11.3
phf_codegen@0.11.2
phf_generator@0.11.1
phf_shared@0.11.3
pin-project-lite@0.2.15
pin-utils@0.1.0
pkg-config@0.3.32
portable-atomic@1.11.0
powerfmt@0.2.0
ppv-lite86@0.2.21
pretty_assertions@1.4.0
proc-macro2@1.0.95
proc-macro-utils@0.10.0
prost@0.11.9
prost-derive@0.11.9
prost-types@0.11.9
pulldown-cmark@0.9.1
quote@1.0.40
quote-use@0.8.4
quote-use-macros@0.8.4
rand@0.8.5
rand_chacha@0.3.1
rand_core@0.6.4
rayon@1.10.0
rayon-core@1.12.1
redox_syscall@0.2.10
redox_syscall@0.4.1
redox_syscall@0.5.6
r-efi@5.2.0
regex@1.11.1
regex-automata@0.4.9
regex-syntax@0.7.5
regex-syntax@0.8.5
relative-path@1.9.3
rustc-demangle@0.1.25
rustc-hash@2.1.1
rustix@0.38.44
rustix@1.0.8
rustversion@1.0.22
ryu@0.2.8
ryu@1.0.17
same-file@1.0.6
scopeguard@1.2.0
scratch@1.0.6
serde@1.0.225
serde_bser@0.4.0
serde_bytes@0.11.17
serde_core@1.0.225
serde_derive@1.0.225
serde_json@1.0.145
serde_jsonrc@0.1.0
serde_repr@0.1.19
serde_spanned@1.0.0
serde-wasm-bindgen@0.6.5
serde_with@3.12.0
serde_with_macros@3.12.0
sharded-slab@0.1.4
shlex@1.3.0
signal-hook-registry@1.4.5
siphasher@1.0.1
slab@0.4.9
smallvec@1.15.0
socket2@0.6.0
sorted_vector_map@0.2.0
stable_deref_trait@1.2.0
starlark_map@0.13.0
static_assertions@1.1.0
static_interner@0.1.1
strsim@0.11.1
structmeta@0.2.0
structmeta-derive@0.2.0
subtle@2.6.1
syn@1.0.109
syn@2.0.101
synstructure@0.13.2
tar@0.4.44
tempfile@3.22.0
termcolor@1.4.1
terminal_size@0.4.2
thiserror@1.0.69
thiserror@2.0.12
thiserror-impl@1.0.69
thiserror-impl@2.0.12
thread_local@1.1.4
tikv-jemallocator@0.6.0
tikv-jemalloc-sys@0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7
time@0.3.41
time-core@0.1.4
time-macros@0.2.22
tinystr@0.7.6
tinyvec@1.8.0
tinyvec_macros@0.1.0
tokio@1.47.1
tokio-macros@2.5.0
tokio-util@0.6.10
toml@0.9.2
toml_datetime@0.7.0
toml_edit@0.23.1
toml_parser@1.0.1
toml_writer@1.0.2
tracing@0.1.41
tracing-attributes@0.1.28
tracing-core@0.1.33
tracing-log@0.2.0
tracing-serde@0.2.0
tracing-subscriber@0.3.20
triomphe@0.1.11
typenum@1.17.0
unicase@2.8.1
unicode-ident@1.0.16
unicode_names2@1.2.2
unicode_names2_generator@1.2.2
unicode-normalization@0.1.24
unicode-segmentation@1.12.0
unicode-width@0.1.12
unicode-width@0.2.1
url@2.5.4
utf16_iter@1.0.5
utf8_iter@1.0.4
utf8parse@0.2.1
valuable@0.1.0
vec1@1.10.1
version_check@0.9.5
walkdir@2.5.0
wasi@0.11.0+wasi-snapshot-preview1
wasi@0.14.2+wasi-0.2.4
wasm-bindgen@0.2.100
wasm-bindgen-backend@0.2.100
wasm-bindgen-macro@0.2.100
wasm-bindgen-macro-support@0.2.100
wasm-bindgen-shared@0.2.100
watchman_client@0.9.0
web-time@1.1.0
which@4.4.2
winapi@0.3.9
winapi-i686-pc-windows-gnu@0.4.0
winapi-util@0.1.5
winapi-x86_64-pc-windows-gnu@0.4.0
windows_aarch64_gnullvm@0.42.1
windows_aarch64_gnullvm@0.48.5
windows_aarch64_gnullvm@0.52.6
windows_aarch64_gnullvm@0.53.0
windows_aarch64_msvc@0.42.1
windows_aarch64_msvc@0.48.5
windows_aarch64_msvc@0.52.6
windows_aarch64_msvc@0.53.0
windows_i686_gnu@0.42.1
windows_i686_gnu@0.48.5
windows_i686_gnu@0.52.6
windows_i686_gnu@0.53.0
windows_i686_gnullvm@0.52.6
windows_i686_gnullvm@0.53.0
windows_i686_msvc@0.42.1
windows_i686_msvc@0.48.5
windows_i686_msvc@0.52.6
windows_i686_msvc@0.53.0
windows-link@0.1.1
windows-sys@0.45.0
windows-sys@0.48.0
windows-sys@0.52.0
windows-sys@0.59.0
windows-sys@0.60.2
windows-targets@0.42.1
windows-targets@0.48.5
windows-targets@0.52.6
windows-targets@0.53.2
windows_x86_64_gnu@0.42.1
windows_x86_64_gnu@0.48.5
windows_x86_64_gnu@0.52.6
windows_x86_64_gnu@0.53.0
windows_x86_64_gnullvm@0.42.1
windows_x86_64_gnullvm@0.48.5
windows_x86_64_gnullvm@0.52.6
windows_x86_64_gnullvm@0.53.0
windows_x86_64_msvc@0.42.1
windows_x86_64_msvc@0.48.5
windows_x86_64_msvc@0.52.6
windows_x86_64_msvc@0.53.0
winnow@0.7.10
wit-bindgen-rt@0.39.0
write16@1.0.0
writeable@0.5.5
xattr@1.5.0
yansi@0.5.1
yansi@1.0.1
yoke@0.7.4
yoke-derive@0.7.4
zerocopy@0.7.35
zerocopy@0.8.25
zerocopy-derive@0.7.35
zerocopy-derive@0.8.25
zerofrom@0.1.4
zerofrom-derive@0.1.4
zerovec@0.10.4
zerovec-derive@0.10.3
zstd@0.13.2
zstd-safe@7.2.1
zstd-sys@2.0.12+zstd.1.5.6
"

declare -A GIT_CRATES=(
	[cxx]="https://github.com/facebookexperimental/cxx;43f8f85eb1b9d99f10f7228ab679997c484ade69;cxx-%commit%"
	[cxx-build]="https://github.com/facebookexperimental/cxx;43f8f85eb1b9d99f10f7228ab679997c484ade69;cxx-%commit%/gen/build"
	[displaydoc]="https://github.com/yaahc/displaydoc;7dc6e324b1788a6b7fb9f3a1953c512923a3e9f0;displaydoc-%commit%"
	[quickcheck]="https://github.com/jakoschiko/quickcheck;6ecdf5bb4b0132ce66670b4d46453aa022ea892c;quickcheck-%commit%"
	[ruff_annotate_snippets]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_annotate_snippets"
	[ruff_python_ast]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_python_ast"
	[ruff_python_parser]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_python_parser"
	[ruff_python_trivia]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_python_trivia"
	[ruff_source_file]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_source_file"
	[ruff_text_size]="https://github.com/astral-sh/ruff;9bee8376a17401f9736b45fdefffb62edc2f1668;ruff-%commit%/crates/ruff_text_size"
)

inherit cargo

DESCRIPTION="A fast type checker and language server for Python"
HOMEPAGE="
	https://pyrefly.org/
	https://github.com/facebook/pyrefly
	https://pypi.org/project/pyrefly/
"
SRC_URI="
	https://github.com/facebook/pyrefly/archive/refs/tags/${PV}.tar.gz -> ${P}.gh.tar.gz
	${CARGO_CRATE_URIS}
"

LICENSE="MIT"
# Crates
LICENSE+="
	0BSD Apache-2.0 Artistic-2 BSD-2 CC0-1.0
	ISC LGPL-2.1+ LGPL-3+ MIT Unicode-3.0 Unlicense ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

QA_FLAGS_IGNORED="usr/bin/${PN}"

PATCHES=(	"${FILESDIR}"/${P}-cargo-toml-paths.patch	)

src_configure() {
	# Requires nightly
	export RUSTC_BOOTSTRAP=1

	cargo_src_configure
}

src_install () {
	cargo_src_install --path "${S}/${PN}"

	einstalldocs
}