Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python310Packages.tbm-utils: improve build and enable tests #243348

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 54 additions & 15 deletions pkgs/development/python-modules/tbm-utils/default.nix
Original file line number Diff line number Diff line change
@@ -1,37 +1,76 @@
{ lib
{ stdenv
, lib
, buildPythonPackage
, fetchPypi
, fetchFromGitHub
, attrs
, pendulum
, poetry-core
, pprintpp
, pytestCheckHook
, pythonRelaxDepsHook
, wrapt
}:

buildPythonPackage rec {
pname = "tbm-utils";
version = "2.6.0";
format = "pyproject";

src = fetchPypi {
inherit pname version;
sha256 = "1v7pb3yirkhzbv1z5i1qp74vl880f56zvzfj68p08b5jxv64hmr3";
src = fetchFromGitHub {
owner = "thebigmunch";
repo = pname;
rev = "refs/tags/${version}";
hash = "sha256-AEKawsAxDSDNkIaXEFFgdEBOY2PpASDrhlDrsnM5eyA=";
};

propagatedBuildInputs = [ attrs pendulum pprintpp wrapt ];

# this versioning was done to prevent normal pip users from encountering
# issues with package failing to build from source, but nixpkgs is better
postPatch = ''
substituteInPlace setup.py \
--replace "'attrs>=18.2,<19.4'" "'attrs'"
substituteInPlace pyproject.toml \
--replace 'poetry>=1.0.0' 'poetry-core' \
--replace 'poetry.masonry.api' 'poetry.core.masonry.api'
'';

# No tests in archive.
doCheck = false;
nativeBuildInputs = [
poetry-core
pythonRelaxDepsHook
];

propagatedBuildInputs = [
attrs
pendulum
pprintpp
wrapt
];

pythonRelaxDeps = [
"attrs"
];

nativeCheckInputs = [
pytestCheckHook
];

disabledTests = lib.optionals stdenv.isDarwin [
# Skip on macOS because /etc/localtime is accessed through the pendulum
# library, which is not allowed in a sandboxed build.
"test_create_parser_filter_dates"
"test_parse_args"
];

disabledTestPaths = lib.optionals stdenv.isDarwin [
# Skip on macOS because /etc/localtime is accessed through the pendulum
# library, which is not allowed in a sandboxed build.
"tests/test_datetime.py"
"tests/test_misc.py"
];

pythonImportsCheck = [
"tbm_utils"
];

meta = {
description = "A commonly-used set of utilities";
homepage = "https://github.com/thebigmunch/tbm-utils";
license = with lib.licenses; [ mit ];
changelog = "https://github.com/thebigmunch/tbm-utils/blob/${version}/CHANGELOG.md";
license = [ lib.licenses.mit ];
};

}