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 pname version src;
39 postPatch = ''
40 cd bindings/python
41 ln -s ${./Cargo.lock} Cargo.lock
42 '';
43 hash = "sha256-4zi29ZdALummwcWxYqDDEPAjKptmLqyYUJzWMrEK4os=";
44 };
45
46 nativeBuildInputs = [
47 rustPlatform.cargoSetupHook
48 rustPlatform.maturinBuildHook
49 ];
50
51 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
52 libiconv
53 ];
54
55 pythonImportsCheck = [ "css_inline" ];
56
57 nativeCheckInputs = [
58 hypothesis
59 pytestCheckHook
60 ];
61
62 disabledTests =
63 [
64 # fails to connect to local server
65 "test_cache"
66 "test_remote_stylesheet"
67 ]
68 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
69 # pyo3_runtime.PanicException: event loop thread panicked
70 "test_invalid_href"
71 ];
72
73 meta = with lib; {
74 description = "Inline CSS into style attributes";
75 homepage = "https://github.com/Stranger6667/css-inline";
76 changelog = "https://github.com/Stranger6667/css-inline/blob/${src.rev}/CHANGELOG.md";
77 license = licenses.mit;
78 maintainers = with maintainers; [ hexa ];
79 };
80}