about summary refs log tree commit diff
path: root/pkgs/development/python-modules/filedate/default.nix
blob: 5317169caa68c30788a373fba3b61ac795de0e1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  python-dateutil,
  setuptools,
}:
buildPythonPackage rec {
  pname = "filedate";
  version = "3.0";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "kubinka0505";
    repo = "filedate";
    rev = version;
    hash = "sha256-HvuGP+QlUlfAUfFmaVVvtPHGdrbWVxghQipnqTTvAQc=";
  };

  sourceRoot = "${src.name}/Files";

  # The repo stores everything in "src" and uses setup.py to move "src" ->
  # "filedate" before calling setup() and then tries to rename "filedate" back
  # to "src" after.
  postPatch = ''
    mv src filedate
    substituteInPlace setup.py \
      --replace-fail "__title__ = os.path.basename(os.path.dirname(os.path.dirname(__file__)))" '__title__ = "filedate"'
    substituteInPlace setup.py \
      --replace-fail "cleanup = True" "cleanup = False"

    # Disable renaming "filedate" dir back to "src"
    substituteInPlace setup.py \
      --replace-fail "if os.path.exists(__title__):" ""
    substituteInPlace setup.py \
      --replace-fail "	os.rename(__title__, directory)" ""
  '';

  build-system = [ setuptools ];

  dependencies = [ python-dateutil ];

  pythonImportsCheck = [ "filedate" ];

  nativeCheckInputs = [ pytestCheckHook ];

  pytestFlagsArray = [ "tests/unit.py" ];

  disabledTests = [ "test_created" ];

  meta = {
    description = "Simple, convenient and cross-platform file date changing library";
    homepage = "https://github.com/kubinka0505/filedate";
    changelog = "https://github.com/kubinka0505/filedate/blob/${src.rev}/Documents/ChangeLog.md";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ thornycrackers ];
  };
}