1{ lib
2, stdenv
3, python3
4, fetchFromGitHub
5, installShellFiles
6}:
7
8with python3.pkgs;
9
10let
11
12 runtimeDeps = ps: with ps; [
13 certifi
14 setuptools
15 pip
16 virtualenv
17 virtualenv-clone
18 ]
19 ++ lib.optionals stdenv.hostPlatform.isAndroid [
20 pyjnius
21 ];
22
23 pythonEnv = python3.withPackages runtimeDeps;
24
25in buildPythonApplication rec {
26 pname = "pipenv";
27 version = "2023.2.4";
28 format = "pyproject";
29
30 src = fetchFromGitHub {
31 owner = "pypa";
32 repo = "pipenv";
33 rev = "refs/tags/v${version}";
34 hash = "sha256-jZOBu4mWyu8U6CGqtYgfcCCDSa0pGqoZEFnXl5IO+JY=";
35 };
36
37 env.LC_ALL = "en_US.UTF-8";
38
39 nativeBuildInputs = [
40 installShellFiles
41 setuptools
42 wheel
43 ];
44
45 postPatch = ''
46 # pipenv invokes python in a subprocess to create a virtualenv
47 # and to call setup.py.
48 # It would use sys.executable, which in our case points to a python that
49 # does not have the required dependencies.
50 substituteInPlace pipenv/core.py \
51 --replace "sys.executable" "'${pythonEnv.interpreter}'"
52 '';
53
54 propagatedBuildInputs = runtimeDeps python3.pkgs;
55
56 preCheck = ''
57 export HOME="$TMPDIR"
58 '';
59
60 nativeCheckInputs = [
61 mock
62 pytestCheckHook
63 pytest-xdist
64 pytz
65 requests
66 ];
67
68 disabledTests = [
69 "test_convert_deps_to_pip"
70 "test_download_file"
71 ];
72
73 disabledTestPaths = [
74 "tests/integration"
75 ];
76
77 postInstall = ''
78 installShellCompletion --cmd pipenv \
79 --bash <(_PIPENV_COMPLETE=bash_source $out/bin/pipenv) \
80 --zsh <(_PIPENV_COMPLETE=zsh_source $out/bin/pipenv) \
81 --fish <(_PIPENV_COMPLETE=fish_source $out/bin/pipenv)
82 '';
83
84 meta = with lib; {
85 description = "Python Development Workflow for Humans";
86 license = licenses.mit;
87 platforms = platforms.all;
88 maintainers = with maintainers; [ berdario ];
89 };
90}