depot/third_party/nixpkgs/pkgs/development/python-modules/libcst/default.nix
Default email 22017988c6 Project import generated by Copybara.
GitOrigin-RevId: c777cdf5c564015d5f63b09cc93bef4178b19b01
2022-04-27 11:35:20 +02:00

93 lines
2.1 KiB
Nix

{ lib
, stdenv
, buildPythonPackage
, dataclasses
, fetchFromGitHub
, hypothesis
, libiconv
, pytestCheckHook
, python
, pythonOlder
, pyyaml
, rustPlatform
, setuptools-rust
, setuptools-scm
, typing-extensions
, typing-inspect
}:
buildPythonPackage rec {
pname = "libcst";
version = "0.4.1";
format = "pyproject";
disabled = pythonOlder "3.6";
src = fetchFromGitHub {
owner = "instagram";
repo = pname;
rev = "v${version}";
sha256 = "sha256-soAlt1KBpCn5JxM1b2LZ3vOpBn9HPGdbm+BBYbyEkfE=";
};
cargoDeps = rustPlatform.fetchCargoTarball {
inherit src;
sourceRoot = "source/${cargoRoot}";
name = "${pname}-${version}";
hash = "sha256:1rz1c0dv3f1h2m5hwdisl3rbqnmifbva4f0c4vygk7rh1q27l515";
};
cargoRoot = "native";
postPatch = ''
# test try to format files, which isn't necessary when consuming releases
sed -i libcst/codegen/generate.py \
-e '/ufmt/c\ pass'
'';
SETUPTOOLS_SCM_PRETEND_VERSION = version;
nativeBuildInputs = [
setuptools-rust
setuptools-scm
rustPlatform.cargoSetupHook
] ++ (with rustPlatform; [ rust.cargo rust.rustc ]);
buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
propagatedBuildInputs = [
hypothesis
typing-extensions
typing-inspect
pyyaml
] ++ lib.optional (pythonOlder "3.7") [
dataclasses
];
checkInputs = [
pytestCheckHook
];
preCheck = ''
${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}
'';
disabledTests = [
# No files are generated
"test_codemod_formatter_error_input"
];
pythonImportsCheck = [
"libcst"
];
meta = with lib; {
description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
homepage = "https://github.com/Instagram/libcst";
license = with licenses; [ mit asl20 psfl ];
maintainers = with maintainers; [ ruuda SuperSandro2000 ];
};
}