1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5
6# build-system
7, rustPlatform
8
9# native darwin dependencies
10, libiconv
11, Security
12
13# tests
14, pytestCheckHook
15, hypothesis
16}:
17
18buildPythonPackage rec {
19 pname = "css-inline";
20 version = "0.10.1";
21 format = "pyproject";
22
23 src = fetchFromGitHub {
24 owner = "Stranger6667";
25 repo = "css-inline";
26 rev = "python-v${version}";
27 hash = "sha256-oBAJv/hAz/itT2WakIw/1X1NvOHX108NoeS6V7k+aG8=";
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.fetchCargoTarball {
38 inherit src;
39 postPatch = ''
40 cd bindings/python
41 ln -s ${./Cargo.lock} Cargo.lock
42 '';
43 name = "${pname}-${version}";
44 hash = "sha256-SFG1nsP4+I0zH8VeyL1eeaTx0tHNIvmx6M0cko0pqIA=";
45 };
46
47 nativeBuildInputs = [
48 rustPlatform.cargoSetupHook
49 rustPlatform.maturinBuildHook
50 ];
51
52 buildInputs = lib.optionals stdenv.isDarwin [
53 libiconv
54 Security
55 ];
56
57 pythonImportsCheck = [
58 "css_inline"
59 ];
60
61 nativeCheckInputs = [
62 hypothesis
63 pytestCheckHook
64 ];
65
66 meta = with lib; {
67 description = "Inline CSS into style attributes";
68 homepage = "https://github.com/Stranger6667/css-inline";
69 changelog = "https://github.com/Stranger6667/css-inline/blob/${src.rev}/CHANGELOG.md";
70 license = licenses.mit;
71 maintainers = with maintainers; [ hexa ];
72 };
73}