21 buildPythonPackage rec {
26 disabled = pythonOlder "3.7";
28 src = fetchFromGitHub {
31 rev = "refs/tags/v${version}";
32 hash = "sha256-kFs7edBWz0GRbgbLDmtpUVi5R+6mYXsJSvceOoPW9ck=";
35 cargoDeps = rustPlatform.fetchCargoTarball {
37 sourceRoot = "${src.name}/${cargoRoot}";
38 name = "${pname}-${version}";
39 hash = "sha256-fhaHiz64NH6S61fSXj4gNxxcuB+ECxWSSmG5StiFr1k=";
45 # https://github.com/Instagram/LibCST/pull/1042
47 name = "remove-distutils.patch";
48 url = "https://github.com/Instagram/LibCST/commit/a6834aa0e6eb78e41549fd1087d7ba60ca4dd237.patch";
49 hash = "sha256-lyIXJhm4UMwdCOso6McDslIvtK7Ar8sF5Zy7qo1nicQ=";
54 # avoid infinite recursion by not formatting the release files
55 substituteInPlace libcst/codegen/generate.py \
56 --replace '"ufmt"' '"true"'
62 rustPlatform.cargoSetupHook
67 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
69 propagatedBuildInputs = [
81 # otherwise import libcst.native fails
82 cp build/lib.*/libcst/native.* libcst/
84 ${python.interpreter} -m libcst.codegen.generate visitors
85 ${python.interpreter} -m libcst.codegen.generate return_types
87 # Can't run all tests due to circular dependency on hypothesmith -> libcst
88 rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests}
92 # No files are generated
93 "test_codemod_formatter_error_input"
96 pythonImportsCheck = [
101 description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
102 homepage = "https://github.com/Instagram/libcst";
103 changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md";
104 license = with licenses; [ mit asl20 psfl ];
105 maintainers = with maintainers; [ ];