1{
2 lib,
3 python3,
4 fetchFromGitHub,
5 runtimeShell,
6 installShellFiles,
7 testers,
8 pdm,
9}:
10
11let
12 python = python3.override {
13 self = python;
14 packageOverrides = _: super: {
15 resolvelib = super.resolvelib.overridePythonAttrs (old: rec {
16 version = "1.1.0";
17 src = old.src.override {
18 rev = version;
19 hash = "sha256-UBdgFN+fvbjz+rp8+rog8FW2jwO/jCfUPV7UehJKiV8=";
20 };
21 });
22 # pdm requires ...... -> jbig2dec which is AGPL only
23 moto = super.moto.overridePythonAttrs (old: rec {
24 doCheck = false;
25 });
26 };
27 };
28in
29python.pkgs.buildPythonApplication rec {
30 pname = "pdm";
31 version = "2.24.2";
32 pyproject = true;
33
34 disabled = python.pkgs.pythonOlder "3.8";
35
36 src = fetchFromGitHub {
37 owner = "pdm-project";
38 repo = "pdm";
39 tag = version;
40 hash = "sha256-z2p7guCQrKpDSYRHaGcHuwoTDsprrvJo9SH3sGBILSQ=";
41 };
42
43 pythonRelaxDeps = [ "hishel" ];
44
45 nativeBuildInputs = [ installShellFiles ];
46
47 build-system = with python.pkgs; [
48 pdm-backend
49 pdm-build-locked
50 ];
51
52 dependencies =
53 with python.pkgs;
54 [
55 blinker
56 dep-logic
57 filelock
58 findpython
59 hishel
60 httpx
61 installer
62 msgpack
63 packaging
64 pbs-installer
65 platformdirs
66 pyproject-hooks
67 python-dotenv
68 resolvelib
69 rich
70 shellingham
71 tomlkit
72 truststore
73 unearth
74 id
75 virtualenv
76 ]
77 ++ httpx.optional-dependencies.socks;
78
79 makeWrapperArgs = [ "--set PDM_CHECK_UPDATE 0" ];
80
81 # Silence network warning during pypaInstallPhase
82 # by disabling latest version check
83 preInstall = ''
84 export PDM_CHECK_UPDATE=0
85 '';
86
87 postInstall = ''
88 export PDM_LOG_DIR=/tmp/pdm/log
89 $out/bin/pdm completion bash >pdm.bash
90 $out/bin/pdm completion fish >pdm.fish
91 $out/bin/pdm completion zsh >pdm.zsh
92 installShellCompletion pdm.{bash,fish,zsh}
93 unset PDM_LOG_DIR
94 '';
95
96 nativeCheckInputs = with python.pkgs; [
97 first
98 pytestCheckHook
99 pytest-mock
100 pytest-xdist
101 pytest-httpserver
102 ];
103
104 disabledTestMarks = [ "network" ];
105
106 preCheck = ''
107 export HOME=$TMPDIR
108 substituteInPlace tests/cli/test_run.py \
109 --replace-fail "/bin/bash" "${runtimeShell}"
110 '';
111
112 disabledTests = [
113 # fails to locate setuptools (maybe upstream bug)
114 "test_convert_setup_py_project"
115 # pythonfinder isn't aware of nix's python infrastructure
116 "test_use_wrapper_python"
117 "test_build_with_no_isolation"
118 "test_run_script_with_inline_metadata"
119
120 # touches the network
121 "test_find_candidates_from_find_links"
122 "test_lock_all_with_excluded_groups"
123 "test_find_interpreters_with_PDM_IGNORE_ACTIVE_VENV"
124 "test_build_distributions"
125 "test_init_project_respect"
126 "test_use_python_write_file_multiple_versions"
127 "test_repository_get_token_from_oidc"
128 "test_repository_get_token_misconfigured_github"
129 ];
130
131 __darwinAllowLocalNetworking = true;
132
133 passthru.tests.version = testers.testVersion { package = pdm; };
134
135 meta = {
136 homepage = "https://pdm-project.org";
137 changelog = "https://github.com/pdm-project/pdm/releases/tag/${version}";
138 description = "Modern Python package and dependency manager supporting the latest PEP standards";
139 license = lib.licenses.mit;
140 maintainers = with lib.maintainers; [
141 cpcloud
142 natsukium
143 misilelab
144 ];
145 mainProgram = "pdm";
146 };
147}