1{
2 lib,
3 buildPythonPackage,
4 distutils,
5 fetchFromGitHub,
6 passlib,
7 pip,
8 pytestCheckHook,
9 pythonOlder,
10 setuptools,
11 twine,
12 watchdog,
13 webtest,
14 build,
15 importlib-resources,
16}:
17
18buildPythonPackage rec {
19 pname = "pypiserver";
20 version = "2.4.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "pypiserver";
27 repo = "pypiserver";
28 tag = "v${version}";
29 hash = "sha256-tbBSZdkZJGcas3PZ3dj7CqAYNH2Mt0a4aXl6t7E+wNY=";
30 };
31
32 postPatch = ''
33 substituteInPlace setup.py \
34 --replace-fail '"setuptools-git>=0.3",' ""
35 '';
36
37 build-system = [
38 setuptools
39 ];
40
41 dependencies = [
42 distutils
43 pip
44 ]
45 ++ lib.optionals (pythonOlder "3.12") [ importlib-resources ];
46
47 optional-dependencies = {
48 passlib = [ passlib ];
49 cache = [ watchdog ];
50 };
51
52 nativeCheckInputs = [
53 pip
54 pytestCheckHook
55 setuptools
56 twine
57 webtest
58 build
59 ]
60 ++ lib.flatten (builtins.attrValues optional-dependencies);
61
62 __darwinAllowLocalNetworking = true;
63
64 # Tests need these permissions in order to use the FSEvents API on macOS.
65 sandboxProfile = ''
66 (allow mach-lookup (global-name "com.apple.FSEvents"))
67 '';
68
69 preCheck = ''
70 export HOME=$TMPDIR
71 '';
72
73 disabledTests = [
74 # Fails to install the package
75 "test_hash_algos"
76 "test_pip_install_authed_succeeds"
77 "test_pip_install_open_succeeds"
78 ];
79
80 disabledTestPaths = [
81 # Test requires docker service running
82 "docker/test_docker.py"
83 ];
84
85 pythonImportsCheck = [ "pypiserver" ];
86
87 meta = with lib; {
88 description = "Minimal PyPI server for use with pip/easy_install";
89 homepage = "https://github.com/pypiserver/pypiserver";
90 changelog = "https://github.com/pypiserver/pypiserver/releases/tag/v${version}";
91 license = with licenses; [
92 mit
93 zlib
94 ];
95 maintainers = with maintainers; [ austinbutler ];
96 mainProgram = "pypi-server";
97 };
98}