1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 rustPlatform,
9
10 # native darwin dependencies
11 libiconv,
12
13 # tests
14 pytestCheckHook,
15 hypothesis,
16}:
17
18buildPythonPackage rec {
19 pname = "css-inline";
20 version = "0.14.6";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "Stranger6667";
25 repo = "css-inline";
26 rev = "python-v${version}";
27 hash = "sha256-x0DxoEKXgMMIlebzL6xVedViGGra2Bx/aox0XiXi+Dc=";
28 };
29
30 postPatch = ''
31 cd bindings/python
32 ln -s ${./Cargo.lock} Cargo.lock
33 '';
34
35 # call `cargo build --release` in bindings/python and copy the
36 # resulting lock file
37 cargoDeps = rustPlatform.fetchCargoVendor {
38 inherit src;
39 postPatch = ''
40 cd bindings/python
41 ln -s ${./Cargo.lock} Cargo.lock
42 '';
43 name = "${pname}-${version}";
44 hash = "sha256-4zi29ZdALummwcWxYqDDEPAjKptmLqyYUJzWMrEK4os=";
45 };
46
47 nativeBuildInputs = [
48 rustPlatform.cargoSetupHook
49 rustPlatform.maturinBuildHook
50 ];
51
52 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
53 libiconv
54 ];
55
56 pythonImportsCheck = [ "css_inline" ];
57
58 nativeCheckInputs = [
59 hypothesis
60 pytestCheckHook
61 ];
62
63 disabledTests =
64 [
65 # fails to connect to local server
66 "test_cache"
67 "test_remote_stylesheet"
68 ]
69 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
70 # pyo3_runtime.PanicException: event loop thread panicked
71 "test_invalid_href"
72 ];
73
74 meta = with lib; {
75 description = "Inline CSS into style attributes";
76 homepage = "https://github.com/Stranger6667/css-inline";
77 changelog = "https://github.com/Stranger6667/css-inline/blob/${src.rev}/CHANGELOG.md";
78 license = licenses.mit;
79 maintainers = with maintainers; [ hexa ];
80 };
81}