nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at 22.05 93 lines 2.1 kB view raw
1{ lib 2, stdenv 3, buildPythonPackage 4, dataclasses 5, fetchFromGitHub 6, hypothesis 7, libiconv 8, pytestCheckHook 9, python 10, pythonOlder 11, pyyaml 12, rustPlatform 13, setuptools-rust 14, setuptools-scm 15, typing-extensions 16, typing-inspect 17}: 18 19buildPythonPackage rec { 20 pname = "libcst"; 21 version = "0.4.1"; 22 format = "pyproject"; 23 24 disabled = pythonOlder "3.6"; 25 26 src = fetchFromGitHub { 27 owner = "instagram"; 28 repo = pname; 29 rev = "v${version}"; 30 sha256 = "sha256-soAlt1KBpCn5JxM1b2LZ3vOpBn9HPGdbm+BBYbyEkfE="; 31 }; 32 33 cargoDeps = rustPlatform.fetchCargoTarball { 34 inherit src; 35 sourceRoot = "source/${cargoRoot}"; 36 name = "${pname}-${version}"; 37 hash = "sha256:1rz1c0dv3f1h2m5hwdisl3rbqnmifbva4f0c4vygk7rh1q27l515"; 38 }; 39 40 cargoRoot = "native"; 41 42 postPatch = '' 43 # test try to format files, which isn't necessary when consuming releases 44 sed -i libcst/codegen/generate.py \ 45 -e '/ufmt/c\ pass' 46 ''; 47 48 SETUPTOOLS_SCM_PRETEND_VERSION = version; 49 50 nativeBuildInputs = [ 51 setuptools-rust 52 setuptools-scm 53 rustPlatform.cargoSetupHook 54 ] ++ (with rustPlatform; [ rust.cargo rust.rustc ]); 55 56 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ]; 57 58 propagatedBuildInputs = [ 59 hypothesis 60 typing-extensions 61 typing-inspect 62 pyyaml 63 ] ++ lib.optional (pythonOlder "3.7") [ 64 dataclasses 65 ]; 66 67 checkInputs = [ 68 pytestCheckHook 69 ]; 70 71 preCheck = '' 72 ${python.interpreter} -m libcst.codegen.generate visitors 73 ${python.interpreter} -m libcst.codegen.generate return_types 74 # Can't run all tests due to circular dependency on hypothesmith -> libcst 75 rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests} 76 ''; 77 78 disabledTests = [ 79 # No files are generated 80 "test_codemod_formatter_error_input" 81 ]; 82 83 pythonImportsCheck = [ 84 "libcst" 85 ]; 86 87 meta = with lib; { 88 description = "Concrete Syntax Tree (CST) parser and serializer library for Python"; 89 homepage = "https://github.com/Instagram/libcst"; 90 license = with licenses; [ mit asl20 psfl ]; 91 maintainers = with maintainers; [ ruuda SuperSandro2000 ]; 92 }; 93}