nixpkgs/pkgs/development/python-modules/cmd2/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

84 lines
1.7 KiB
Nix

{
lib,
stdenv,
attrs,
buildPythonPackage,
colorama,
fetchPypi,
glibcLocales,
importlib-metadata,
pyperclip,
pytest-mock,
pytestCheckHook,
pythonOlder,
setuptools-scm,
typing-extensions,
wcwidth,
}:
buildPythonPackage rec {
pname = "cmd2";
version = "2.4.3";
format = "setuptools";
disabled = pythonOlder "3.6";
src = fetchPypi {
inherit pname version;
hash = "sha256-cYc8Efcr0Z4rHbV4IUcW8NT3yPolAJPGASZamnF97lI=";
};
LC_ALL = "en_US.UTF-8";
buildInputs = [ setuptools-scm ];
propagatedBuildInputs =
[
attrs
colorama
pyperclip
wcwidth
]
++ lib.optionals (pythonOlder "3.8") [
typing-extensions
importlib-metadata
];
nativeCheckInputs = [
pytestCheckHook
glibcLocales
pytest-mock
];
disabledTests = [
# Don't require vim for tests, it causes lots of rebuilds
"test_find_editor_not_specified"
"test_transcript"
];
postPatch =
''
sed -i "/--cov/d" setup.cfg
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Fake the impure dependencies pbpaste and pbcopy
mkdir bin
echo '#!${stdenv.shell}' > bin/pbpaste
echo '#!${stdenv.shell}' > bin/pbcopy
chmod +x bin/{pbcopy,pbpaste}
export PATH=$(realpath bin):$PATH
'';
doCheck = !stdenv.hostPlatform.isDarwin;
pythonImportsCheck = [ "cmd2" ];
meta = with lib; {
description = "Enhancements for standard library's cmd module";
homepage = "https://github.com/python-cmd2/cmd2";
changelog = "https://github.com/python-cmd2/cmd2/releases/tag/${version}";
license = with licenses; [ mit ];
maintainers = with maintainers; [ teto ];
};
}