btrbk: add mainProgram
[NixPkgs.git] / pkgs / by-name / pi / pipenv / package.nix
blob0843e6162227b8f32de4523d44e978e2bb9b4cd6
1 { lib
2 , stdenv
3 , python3
4 , fetchFromGitHub
5 , installShellFiles
6 , pipenv
7 , runCommand
8 }:
10 with python3.pkgs;
12 let
14   runtimeDeps = ps: with ps; [
15     certifi
16     setuptools
17     pip
18     virtualenv
19     virtualenv-clone
20   ]
21   ++ lib.optionals stdenv.hostPlatform.isAndroid [
22     pyjnius
23   ];
25   pythonEnv = python3.withPackages runtimeDeps;
27 in buildPythonApplication rec {
28   pname = "pipenv";
29   version = "2024.2.0";
30   format = "pyproject";
32   src = fetchFromGitHub {
33     owner = "pypa";
34     repo = "pipenv";
35     rev = "refs/tags/v${version}";
36     hash = "sha256-5gq1kXVNAMH/AeovpUStcZffXN4GfXj3wJ7lW4qebRM=";
37   };
39   env.LC_ALL = "en_US.UTF-8";
41   nativeBuildInputs = [
42     installShellFiles
43     setuptools
44     wheel
45   ];
47   postPatch = ''
48     # pipenv invokes python in a subprocess to create a virtualenv
49     # and to call setup.py.
50     # It would use sys.executable, which in our case points to a python that
51     # does not have the required dependencies.
52     substituteInPlace pipenv/utils/virtualenv.py \
53       --replace "sys.executable" "'${pythonEnv.interpreter}'"
54   '';
56   propagatedBuildInputs = runtimeDeps python3.pkgs;
58   preCheck = ''
59     export HOME="$TMPDIR"
60   '';
62   nativeCheckInputs = [
63     mock
64     pytestCheckHook
65     pytest-xdist
66     pytz
67     requests
68   ];
70   disabledTests = [
71     # this test wants access to the internet
72     "test_download_file"
73   ];
75   disabledTestPaths = [
76     # many of these tests want access to the internet
77     "tests/integration"
78   ];
80   passthru.tests = {
81     verify-venv-patch = runCommand "${pname}-test-verify-venv-patch" {} ''
82       export PIPENV_VENV_IN_PROJECT=1
84       # "pipenv install" should be able to create a venv
85       ${pipenv}/bin/pipenv install
87        # the venv exists
88       [ -d .venv ]
90       touch $out
91     '';
92   };
94   postInstall = ''
95     installShellCompletion --cmd pipenv \
96       --bash <(_PIPENV_COMPLETE=bash_source $out/bin/pipenv) \
97       --zsh <(_PIPENV_COMPLETE=zsh_source $out/bin/pipenv) \
98       --fish <(_PIPENV_COMPLETE=fish_source $out/bin/pipenv)
99   '';
101   meta = with lib; {
102     description = "Python Development Workflow for Humans";
103     license = licenses.mit;
104     platforms = platforms.all;
105     maintainers = with maintainers; [ berdario ];
106   };