1{
2 lib,
3 python3Packages,
4 fetchFromGitHub,
5}:
6
7python3Packages.buildPythonApplication rec {
8 pname = "cloudsmith-cli";
9 version = "1.8.3";
10 pyproject = true;
11
12 src = fetchFromGitHub {
13 owner = "cloudsmith-io";
14 repo = "cloudsmith-cli";
15 tag = "v${version}";
16 hash = "sha256-PYqOj6nHjJrG7Ndc5vm//E8mjk4xZFVQopFqiWtH5ZQ=";
17 };
18
19 postPatch = ''
20 # Fix compatibility with urllib3 >= 2.0 - method_whitelist renamed to allowed_methods
21 # https://github.com/cloudsmith-io/cloudsmith-cli/pull/148
22 substituteInPlace cloudsmith_cli/core/rest.py \
23 --replace-fail 'method_whitelist=False' 'allowed_methods=False'
24 substituteInPlace setup.py \
25 --replace-fail 'urllib3<2.0' 'urllib3'
26 '';
27
28 build-system = with python3Packages; [ setuptools ];
29
30 dependencies = with python3Packages; [
31 click
32 click-configfile
33 click-didyoumean
34 click-spinner
35 cloudsmith-api
36 keyring
37 requests
38 requests-toolbelt
39 semver
40 urllib3
41 ];
42
43 nativeCheckInputs = with python3Packages; [
44 pytestCheckHook
45 pytest-cov-stub
46 freezegun
47 httpretty
48 ];
49
50 pythonImportsCheck = [
51 "cloudsmith_cli"
52 ];
53
54 preCheck = ''
55 # When test_implicit_retry_for_status_codes calls initialise_api(),
56 # and no user strings like LOGNAME or USER is set, getpass will call
57 # getpwuid() which will then fail when we enable auto-allocate-uids.
58 export USER=nixbld
59 # https://github.com/NixOS/nixpkgs/issues/255262
60 cd "$out"
61 '';
62
63 meta = {
64 homepage = "https://help.cloudsmith.io/docs/cli/";
65 description = "Cloudsmith Command Line Interface";
66 mainProgram = "cloudsmith";
67 changelog = "https://github.com/cloudsmith-io/cloudsmith-cli/blob/v${version}/CHANGELOG.md";
68 maintainers = with lib.maintainers; [ usertam ];
69 license = lib.licenses.asl20;
70 platforms = lib.platforms.unix;
71 };
72}