1{ lib
2, stdenv
3, anyio
4, buildPythonPackage
5, cargo
6, fetchFromGitHub
7, rustPlatform
8, rustc
9, setuptools-rust
10, pythonOlder
11, dirty-equals
12, pytest-mock
13, pytest-timeout
14, pytestCheckHook
15, python
16, CoreServices
17, libiconv
18}:
19
20buildPythonPackage rec {
21 pname = "watchfiles";
22 version = "0.19.0";
23 format = "pyproject";
24
25 disabled = pythonOlder "3.7";
26
27 src = fetchFromGitHub {
28 owner = "samuelcolvin";
29 repo = pname;
30 rev = "refs/tags/v${version}";
31 hash = "sha256-NmmeoaIfFMNKCcjH6tPnkpflkN35bKlT76MqF9W8LBc=";
32 };
33
34 cargoDeps = rustPlatform.fetchCargoTarball {
35 inherit src;
36 name = "${pname}-${version}";
37 hash = "sha256-9ruk3PMcWNLOIGth5fo91/miyF17lgERWL3F4y4as18=";
38 };
39
40 buildInputs = lib.optionals stdenv.isDarwin [
41 CoreServices
42 libiconv
43 ];
44
45 nativeBuildInputs = [
46 rustPlatform.cargoSetupHook
47 rustPlatform.maturinBuildHook
48 cargo
49 rustc
50 ];
51
52 propagatedBuildInputs = [
53 anyio
54 ];
55
56 nativeCheckInputs = [
57 dirty-equals
58 pytest-mock
59 pytest-timeout
60 pytestCheckHook
61 ];
62
63 postPatch = ''
64 sed -i "/^requires-python =.*/a version = '${version}'" pyproject.toml
65 '';
66
67 preCheck = ''
68 rm -rf watchfiles
69 '';
70
71 pythonImportsCheck = [
72 "watchfiles"
73 ];
74
75 meta = with lib; {
76 description = "File watching and code reload";
77 homepage = "https://watchfiles.helpmanual.io/";
78 license = licenses.mit;
79 maintainers = with maintainers; [ fab ];
80 };
81}