1{ stdenv, python3Packages, glibcLocales, rustPlatform, pkgconfig, openssl }:
2
3# Packaging documentation at:
4# https://github.com/untitaker/vdirsyncer/blob/master/docs/packaging.rst
5let
6 pythonPackages = python3Packages;
7 version = "0.17.0a3";
8 pname = "vdirsyncer";
9 name = pname + "-" + version;
10 src = pythonPackages.fetchPypi {
11 inherit pname version;
12 sha256 = "1n7izfa5x9mh0b4zp20gd8qxfcca5wpjh834bsbi5pk6zam5pfdy";
13 };
14 native = rustPlatform.buildRustPackage {
15 name = name + "-native";
16 inherit src;
17 sourceRoot = name + "/rust";
18 cargoSha256 = "08xq9q5fx37azzkqqgwcnds1yd8687gh26dsl3ivql5h13fa2w3q";
19 buildInputs = [ pkgconfig openssl ];
20 };
21in pythonPackages.buildPythonApplication rec {
22 inherit version pname src native;
23
24 propagatedBuildInputs = with pythonPackages; [
25 click click-log click-threading
26 requests_toolbelt
27 requests
28 requests_oauthlib # required for google oauth sync
29 atomicwrites
30 milksnake
31 shippai
32 ];
33
34 buildInputs = with pythonPackages; [ setuptools_scm ];
35
36 checkInputs = with pythonPackages; [ hypothesis pytest pytest-localserver pytest-subtesthack ] ++ [ glibcLocales ];
37
38 postPatch = ''
39 sed -i 's/spec.add_external_build(cmd=cmd/spec.add_external_build(cmd="true"/g' setup.py
40 '';
41
42 preBuild = ''
43 mkdir -p rust/target/release
44 ln -s ${native}/bin/libvdirsyncer_rustext* rust/target/release/
45 '';
46
47 LC_ALL = "en_US.utf8";
48
49 checkPhase = ''
50 rm -rf vdirsyncer
51 export PYTHONPATH=$out/${pythonPackages.python.sitePackages}:$PYTHONPATH
52 make DETERMINISTIC_TESTS=true test
53 '';
54
55 meta = with stdenv.lib; {
56 homepage = https://github.com/pimutils/vdirsyncer;
57 description = "Synchronize calendars and contacts";
58 maintainers = with maintainers; [ jgeerds ];
59 platforms = platforms.all;
60 license = licenses.mit;
61 };
62}