nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 django,
5 django-allauth,
6 djangorestframework,
7 djangorestframework-simplejwt,
8 fetchFromGitHub,
9 fetchpatch,
10 python,
11 responses,
12 setuptools,
13 unittest-xml-reporting,
14 pytestCheckHook,
15 pytest-django,
16}:
17
18buildPythonPackage rec {
19 pname = "dj-rest-auth";
20 version = "7.0.2";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "iMerica";
25 repo = "dj-rest-auth";
26 tag = version;
27 hash = "sha256-tgcEnB9n9pq+TBde8udsr8osdAAJqmXaaU1Wt2psPIw=";
28 };
29
30 patches = [
31 # See https://github.com/iMerica/dj-rest-auth/pull/683
32 (fetchpatch {
33 name = "djangorestframework-simplejwt_5.5_compatibility.patch";
34 url = "https://github.com/iMerica/dj-rest-auth/commit/cc5587e4e3f327697709f3f0d491650bff5464e7.diff";
35 hash = "sha256-2LahibxuNECAfjqsbNs2ezaWt1VH0ZBNwSNWCZwIe8I=";
36 })
37 ];
38
39 postPatch = ''
40 substituteInPlace setup.py \
41 --replace-fail "==" ">="
42 '';
43
44 build-system = [ setuptools ];
45
46 buildInputs = [ django ];
47
48 dependencies = [ djangorestframework ];
49
50 optional-dependencies.with_social = [
51 django-allauth
52 ]
53 ++ django-allauth.optional-dependencies.socialaccount;
54
55 nativeCheckInputs = [
56 djangorestframework-simplejwt
57 responses
58 unittest-xml-reporting
59 ]
60 ++ optional-dependencies.with_social;
61
62 checkInputs = [
63 pytestCheckHook
64 pytest-django
65 ];
66
67 env.DJANGO_SETTINGS_MODULE = "dj_rest_auth.tests.settings";
68
69 preCheck = ''
70 # Make tests module available for the checkPhase
71 export PYTHONPATH=$out/${python.sitePackages}/dj_rest_auth:$PYTHONPATH
72 '';
73
74 disabledTests = [
75 # Test connects to graph.facebook.com
76 "TestSocialLoginSerializer"
77 # claim[user_id] is "1" (str) vs 1 (int)
78 "test_custom_jwt_claims"
79 "test_custom_jwt_claims_cookie_w_authentication"
80 ];
81
82 disabledTestPaths = [
83 # Test fails with > django-allauth 65.4
84 # See: https://github.com/iMerica/dj-rest-auth/pull/681#issuecomment-3034953311
85 "dj_rest_auth/tests/test_social.py"
86 ];
87
88 pythonImportsCheck = [ "dj_rest_auth" ];
89
90 meta = {
91 description = "Authentication for Django Rest Framework";
92 homepage = "https://github.com/iMerica/dj-rest-auth";
93 changelog = "https://github.com/iMerica/dj-rest-auth/releases/tag/${src.tag}";
94 license = lib.licenses.mit;
95 maintainers = with lib.maintainers; [ onny ];
96 };
97}