Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 cargo,
7 hypothesmith,
8 isPy313,
9 libcst,
10 libiconv,
11 pytestCheckHook,
12 pyyaml,
13 pyyaml-ft,
14 rustPlatform,
15 rustc,
16 setuptools-rust,
17 setuptools-scm,
18 ufmt,
19}:
20
21buildPythonPackage rec {
22 pname = "libcst";
23 version = "1.8.6";
24 pyproject = true;
25
26 src = fetchFromGitHub {
27 owner = "Instagram";
28 repo = "LibCST";
29 tag = "v${version}";
30 hash = "sha256-AJm3grS+I/NXZ8ame4rmHPOxRHGO0Ofo35RtSDO2tyI=";
31 };
32
33 cargoDeps = rustPlatform.fetchCargoVendor {
34 inherit
35 pname
36 version
37 src
38 cargoRoot
39 ;
40 hash = "sha256-7/Yf2yn7wjW0CDG1Ha3SsvOIytbU1bJCpR9WFAFiPEA=";
41 };
42
43 cargoRoot = "native";
44
45 build-system = [
46 setuptools-rust
47 setuptools-scm
48 ];
49
50 nativeBuildInputs = [
51 rustPlatform.cargoSetupHook
52 cargo
53 rustc
54 ];
55
56 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
57
58 dependencies = [
59 (if isPy313 then pyyaml-ft else pyyaml)
60 ];
61
62 nativeCheckInputs = [
63 hypothesmith
64 pytestCheckHook
65 ufmt
66 ];
67
68 preCheck = ''
69 # import from $out instead
70 rm libcst/__init__.py
71 '';
72
73 disabledTests = [
74 # FIXME package pyre-test
75 "TypeInferenceProviderTest"
76 # we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out
77 "test_codegen_clean_visitor_functions"
78 "test_codegen_clean_matcher_classes"
79 "test_codegen_clean_return_types"
80 ];
81
82 # circular dependency on hypothesmith and ufmt
83 doCheck = false;
84
85 passthru.tests = {
86 pytest = libcst.overridePythonAttrs { doCheck = true; };
87 };
88
89 pythonImportsCheck = [ "libcst" ];
90
91 meta = {
92 description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
93 homepage = "https://github.com/Instagram/LibCST";
94 changelog = "https://github.com/Instagram/LibCST/blob/${src.tag}/CHANGELOG.md";
95 license = with lib.licenses; [
96 mit
97 asl20
98 psfl
99 ];
100 maintainers = with lib.maintainers; [ dotlambda ];
101 };
102}