2021-03-09 03:18:52 +00:00
|
|
|
{ lib
|
2022-04-27 09:35:20 +00:00
|
|
|
, stdenv
|
2021-03-09 03:18:52 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchFromGitHub
|
|
|
|
, hypothesis
|
2022-04-27 09:35:20 +00:00
|
|
|
, libiconv
|
2022-03-30 09:31:56 +00:00
|
|
|
, pytestCheckHook
|
2021-06-28 23:13:55 +00:00
|
|
|
, python
|
|
|
|
, pythonOlder
|
2021-03-09 03:18:52 +00:00
|
|
|
, pyyaml
|
2022-04-15 01:41:22 +00:00
|
|
|
, rustPlatform
|
|
|
|
, setuptools-rust
|
2021-12-26 17:43:05 +00:00
|
|
|
, setuptools-scm
|
2021-03-09 03:18:52 +00:00
|
|
|
, typing-extensions
|
|
|
|
, typing-inspect
|
|
|
|
}:
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "libcst";
|
2022-06-26 10:26:21 +00:00
|
|
|
version = "0.4.3";
|
2022-04-15 01:41:22 +00:00
|
|
|
format = "pyproject";
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
disabled = pythonOlder "3.7";
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "instagram";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-06-26 10:26:21 +00:00
|
|
|
sha256 = "sha256-Lm62rVL5f+fu4KzOQMroM0Eu27l5v2dkGtRiIVPFNhg=";
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
inherit src;
|
|
|
|
sourceRoot = "source/${cargoRoot}";
|
|
|
|
name = "${pname}-${version}";
|
2022-06-26 10:26:21 +00:00
|
|
|
hash = "sha256-i5BYYiILadKEPIJOaWdG1lZNSHfNQnwmc5j0D1jg/kc=";
|
2022-04-15 01:41:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
cargoRoot = "native";
|
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
postPatch = ''
|
|
|
|
# test try to format files, which isn't necessary when consuming releases
|
|
|
|
sed -i libcst/codegen/generate.py \
|
|
|
|
-e '/ufmt/c\ pass'
|
|
|
|
'';
|
|
|
|
|
|
|
|
SETUPTOOLS_SCM_PRETEND_VERSION = version;
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2022-04-15 01:41:22 +00:00
|
|
|
setuptools-rust
|
2021-12-26 17:43:05 +00:00
|
|
|
setuptools-scm
|
2022-04-15 01:41:22 +00:00
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
] ++ (with rustPlatform; [ rust.cargo rust.rustc ]);
|
2021-12-26 17:43:05 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
typing-extensions
|
|
|
|
typing-inspect
|
|
|
|
pyyaml
|
|
|
|
];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkInputs = [
|
2022-06-26 10:26:21 +00:00
|
|
|
hypothesis
|
2022-03-30 09:31:56 +00:00
|
|
|
pytestCheckHook
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
2020-10-16 20:44:37 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
${python.interpreter} -m libcst.codegen.generate visitors
|
|
|
|
${python.interpreter} -m libcst.codegen.generate return_types
|
|
|
|
# Can't run all tests due to circular dependency on hypothesmith -> libcst
|
|
|
|
rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests}
|
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 = [
|
|
|
|
# No files are generated
|
|
|
|
"test_codemod_formatter_error_input"
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
pythonImportsCheck = [
|
|
|
|
"libcst"
|
|
|
|
];
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
meta = with lib; {
|
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";
|
|
|
|
license = with licenses; [ mit asl20 psfl ];
|
2022-06-26 10:26:21 +00:00
|
|
|
maintainers = with maintainers; [ SuperSandro2000 ];
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
}
|