nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, python3
4, fetchPypi
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
29 src = fetchPypi {
30 inherit pname version;
31 sha256 = "sha256-GKPrpRnjbVnw1af5xCvSaFIeS5t7PRvWrc8TFWkyMnU=";
32 };
33
34 LC_ALL = "en_US.UTF-8";
35
36 nativeBuildInputs = [ installShellFiles ];
37
38 postPatch = ''
39 # pipenv invokes python in a subprocess to create a virtualenv
40 # and to call setup.py.
41 # It would use sys.executable, which in our case points to a python that
42 # does not have the required dependencies.
43 substituteInPlace pipenv/core.py \
44 --replace "sys.executable" "'${pythonEnv.interpreter}'"
45 '';
46
47 propagatedBuildInputs = runtimeDeps python3.pkgs;
48
49 postInstall = ''
50 installShellCompletion --cmd pipenv \
51 --bash <(_PIPENV_COMPLETE=bash_source $out/bin/pipenv) \
52 --zsh <(_PIPENV_COMPLETE=zsh_source $out/bin/pipenv) \
53 --fish <(_PIPENV_COMPLETE=fish_source $out/bin/pipenv)
54 '';
55
56 doCheck = true;
57 checkPhase = ''
58 export HOME=$(mktemp -d)
59 cp -r --no-preserve=mode ${wheel.src} $HOME/wheel-src
60 $out/bin/pipenv install $HOME/wheel-src
61 '';
62
63 meta = with lib; {
64 description = "Python Development Workflow for Humans";
65 license = licenses.mit;
66 platforms = platforms.all;
67 maintainers = with maintainers; [ berdario ];
68 };
69}