2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchFromGitHub,
|
2024-09-19 14:19:46 +00:00
|
|
|
callPackage,
|
2024-06-05 15:53:02 +00:00
|
|
|
cargo,
|
2024-09-19 14:19:46 +00:00
|
|
|
hypothesmith,
|
|
|
|
libcst,
|
2024-06-05 15:53:02 +00:00
|
|
|
libiconv,
|
|
|
|
pytestCheckHook,
|
|
|
|
python,
|
|
|
|
pythonOlder,
|
|
|
|
pyyaml,
|
|
|
|
rustPlatform,
|
|
|
|
rustc,
|
|
|
|
setuptools-rust,
|
|
|
|
setuptools-scm,
|
|
|
|
typing-extensions,
|
|
|
|
typing-inspect,
|
2024-09-19 14:19:46 +00:00
|
|
|
ufmt,
|
2021-03-09 03:18:52 +00:00
|
|
|
}:
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "libcst";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "1.4.0";
|
2024-09-19 14:19:46 +00:00
|
|
|
pyproject = true;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
disabled = pythonOlder "3.9";
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "instagram";
|
2023-08-04 22:07:22 +00:00
|
|
|
repo = "libcst";
|
2022-08-12 12:06:08 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-H0YO8ILWOyhYdosNRWQQ9wziFk0syKSG3vF2zuYkL2k=";
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
2023-08-04 22:07:22 +00:00
|
|
|
sourceRoot = "${src.name}/${cargoRoot}";
|
2022-04-15 01:41:22 +00:00
|
|
|
name = "${pname}-${version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-AcqHn3A7WCVyVnOBD96k4pxokhzgmCWOipK/DrIAQkU=";
|
2022-04-15 01:41:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoRoot = "native";
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
build-system = [
|
2022-04-15 01:41:22 +00:00
|
|
|
setuptools-rust
|
2021-12-26 17:43:05 +00:00
|
|
|
setuptools-scm
|
2024-09-19 14:19:46 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2022-04-15 01:41:22 +00:00
|
|
|
rustPlatform.cargoSetupHook
|
2023-05-24 13:37:59 +00:00
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
];
|
2021-12-26 17:43:05 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
dependencies = [
|
2021-06-28 23:13:55 +00:00
|
|
|
typing-extensions
|
|
|
|
typing-inspect
|
|
|
|
pyyaml
|
|
|
|
];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2024-09-19 14:19:46 +00:00
|
|
|
hypothesmith
|
2022-03-30 09:31:56 +00:00
|
|
|
pytestCheckHook
|
2024-09-19 14:19:46 +00:00
|
|
|
ufmt
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
2020-10-16 20:44:37 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
2024-09-19 14:19:46 +00:00
|
|
|
# import from $out instead
|
|
|
|
rm libcst/__init__.py
|
2020-10-16 20:44:37 +00:00
|
|
|
'';
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
disabledTests = [
|
2024-09-19 14:19:46 +00:00
|
|
|
# FIXME package pyre-test
|
|
|
|
"TypeInferenceProviderTest"
|
|
|
|
# we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out
|
|
|
|
"test_codegen_clean_visitor_functions"
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# circular dependency on hypothesmith and ufmt
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
passthru.tests = {
|
|
|
|
pytest = libcst.overridePythonAttrs { doCheck = true; };
|
|
|
|
};
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
pythonImportsCheck = [ "libcst" ];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
meta = {
|
2021-06-28 23:13:55 +00:00
|
|
|
description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
|
2020-10-16 20:44:37 +00:00
|
|
|
homepage = "https://github.com/Instagram/libcst";
|
2023-10-19 13:55:26 +00:00
|
|
|
changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md";
|
2024-09-19 14:19:46 +00:00
|
|
|
license = with lib.licenses; [
|
2024-06-05 15:53:02 +00:00
|
|
|
mit
|
|
|
|
asl20
|
|
|
|
psfl
|
|
|
|
];
|
2024-09-19 14:19:46 +00:00
|
|
|
maintainers = with lib.maintainers; [ dotlambda ];
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
}
|