about summary refs log tree commit diff
path: root/pkgs/development/python-modules/libcst/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/python-modules/libcst/default.nix')
-rw-r--r--pkgs/development/python-modules/libcst/default.nix70
1 files changed, 32 insertions, 38 deletions
diff --git a/pkgs/development/python-modules/libcst/default.nix b/pkgs/development/python-modules/libcst/default.nix
index ba7e0fa5340e0..3ccf4c8e12fbe 100644
--- a/pkgs/development/python-modules/libcst/default.nix
+++ b/pkgs/development/python-modules/libcst/default.nix
@@ -3,9 +3,10 @@
   stdenv,
   buildPythonPackage,
   fetchFromGitHub,
-  fetchpatch,
+  callPackage,
   cargo,
-  hypothesis,
+  hypothesmith,
+  libcst,
   libiconv,
   pytestCheckHook,
   python,
@@ -17,94 +18,87 @@
   setuptools-scm,
   typing-extensions,
   typing-inspect,
+  ufmt,
 }:
 
 buildPythonPackage rec {
   pname = "libcst";
-  version = "1.1.0";
-  format = "pyproject";
+  version = "1.4.0";
+  pyproject = true;
 
-  disabled = pythonOlder "3.7";
+  disabled = pythonOlder "3.9";
 
   src = fetchFromGitHub {
     owner = "instagram";
     repo = "libcst";
     rev = "refs/tags/v${version}";
-    hash = "sha256-kFs7edBWz0GRbgbLDmtpUVi5R+6mYXsJSvceOoPW9ck=";
+    hash = "sha256-H0YO8ILWOyhYdosNRWQQ9wziFk0syKSG3vF2zuYkL2k=";
   };
 
   cargoDeps = rustPlatform.fetchCargoTarball {
     inherit src;
     sourceRoot = "${src.name}/${cargoRoot}";
     name = "${pname}-${version}";
-    hash = "sha256-fhaHiz64NH6S61fSXj4gNxxcuB+ECxWSSmG5StiFr1k=";
+    hash = "sha256-AcqHn3A7WCVyVnOBD96k4pxokhzgmCWOipK/DrIAQkU=";
   };
 
   cargoRoot = "native";
 
-  patches = [
-    # https://github.com/Instagram/LibCST/pull/1042
-    (fetchpatch {
-      name = "remove-distutils.patch";
-      url = "https://github.com/Instagram/LibCST/commit/a6834aa0e6eb78e41549fd1087d7ba60ca4dd237.patch";
-      hash = "sha256-lyIXJhm4UMwdCOso6McDslIvtK7Ar8sF5Zy7qo1nicQ=";
-    })
+  build-system = [
+    setuptools-rust
+    setuptools-scm
   ];
 
-  postPatch = ''
-    # avoid infinite recursion by not formatting the release files
-    substituteInPlace libcst/codegen/generate.py \
-      --replace '"ufmt"' '"true"'
-  '';
-
   nativeBuildInputs = [
-    setuptools-rust
-    setuptools-scm
     rustPlatform.cargoSetupHook
     cargo
     rustc
   ];
 
-  buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
+  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
 
-  propagatedBuildInputs = [
+  dependencies = [
     typing-extensions
     typing-inspect
     pyyaml
   ];
 
   nativeCheckInputs = [
-    hypothesis
+    hypothesmith
     pytestCheckHook
+    ufmt
   ];
 
   preCheck = ''
-    # otherwise import libcst.native fails
-    cp build/lib.*/libcst/native.* libcst/
-
-    ${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}
+    # import from $out instead
+    rm libcst/__init__.py
   '';
 
   disabledTests = [
-    # No files are generated
-    "test_codemod_formatter_error_input"
+    # FIXME package pyre-test
+    "TypeInferenceProviderTest"
+    # we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out
+    "test_codegen_clean_visitor_functions"
   ];
 
+  # circular dependency on hypothesmith and ufmt
+  doCheck = false;
+
+  passthru.tests = {
+    pytest = libcst.overridePythonAttrs { doCheck = true; };
+  };
+
   pythonImportsCheck = [ "libcst" ];
 
-  meta = with lib; {
+  meta = {
     description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
     homepage = "https://github.com/Instagram/libcst";
     changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md";
-    license = with licenses; [
+    license = with lib.licenses; [
       mit
       asl20
       psfl
     ];
-    maintainers = with maintainers; [ ];
+    maintainers = with lib.maintainers; [ dotlambda ];
   };
 }