Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 cargo, 7 hypothesis, 8 libiconv, 9 pytestCheckHook, 10 python, 11 pythonOlder, 12 pyyaml, 13 rustPlatform, 14 rustc, 15 setuptools-rust, 16 setuptools-scm, 17 typing-extensions, 18 typing-inspect, 19}: 20 21buildPythonPackage rec { 22 pname = "libcst"; 23 version = "1.4.0"; 24 format = "pyproject"; 25 26 disabled = pythonOlder "3.7"; 27 28 src = fetchFromGitHub { 29 owner = "instagram"; 30 repo = "libcst"; 31 rev = "refs/tags/v${version}"; 32 hash = "sha256-H0YO8ILWOyhYdosNRWQQ9wziFk0syKSG3vF2zuYkL2k="; 33 }; 34 35 cargoDeps = rustPlatform.fetchCargoTarball { 36 inherit src; 37 sourceRoot = "${src.name}/${cargoRoot}"; 38 name = "${pname}-${version}"; 39 hash = "sha256-AcqHn3A7WCVyVnOBD96k4pxokhzgmCWOipK/DrIAQkU="; 40 }; 41 42 cargoRoot = "native"; 43 44 postPatch = '' 45 # avoid infinite recursion by not formatting the release files 46 substituteInPlace libcst/codegen/generate.py \ 47 --replace '"ufmt"' '"true"' 48 ''; 49 50 nativeBuildInputs = [ 51 setuptools-rust 52 setuptools-scm 53 rustPlatform.cargoSetupHook 54 cargo 55 rustc 56 ]; 57 58 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ]; 59 60 propagatedBuildInputs = [ 61 typing-extensions 62 typing-inspect 63 pyyaml 64 ]; 65 66 nativeCheckInputs = [ 67 hypothesis 68 pytestCheckHook 69 ]; 70 71 preCheck = '' 72 # otherwise import libcst.native fails 73 cp build/lib.*/libcst/native.* libcst/ 74 75 ${python.interpreter} -m libcst.codegen.generate visitors 76 ${python.interpreter} -m libcst.codegen.generate return_types 77 78 # Can't run all tests due to circular dependency on hypothesmith -> libcst 79 rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests} 80 ''; 81 82 disabledTests = [ 83 # No files are generated 84 "test_codemod_formatter_error_input" 85 ]; 86 87 pythonImportsCheck = [ "libcst" ]; 88 89 meta = with lib; { 90 description = "Concrete Syntax Tree (CST) parser and serializer library for Python"; 91 homepage = "https://github.com/Instagram/libcst"; 92 changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md"; 93 license = with licenses; [ 94 mit 95 asl20 96 psfl 97 ]; 98 maintainers = [ ]; 99 }; 100}