python3Packages.backports-zoneinfo: patch in zoneinfo and enable tests

This commit is contained in:
Martin Weinelt 2021-06-03 03:25:41 +02:00
parent 2e88b6f989
commit 647a0621ff
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 39 additions and 3 deletions

View file

@ -1,6 +1,9 @@
{ lib, buildPythonPackage, fetchFromGitHub { lib, buildPythonPackage, fetchFromGitHub
, pythonOlder , pythonOlder
, python
, substituteAll
, importlib-resources , importlib-resources
, tzdata
, hypothesis , hypothesis
, pytestCheckHook , pytestCheckHook
}: }:
@ -16,7 +19,17 @@ buildPythonPackage rec {
sha256 = "sha256-00xdDOVdDanfsjQTd3yjMN2RFGel4cWRrAA3CvSnl24="; sha256 = "sha256-00xdDOVdDanfsjQTd3yjMN2RFGel4cWRrAA3CvSnl24=";
}; };
propagatedBuildInputs = lib.optionals (pythonOlder "3.7") [ patches = [
(substituteAll {
name = "zoneinfo-path";
src = ./zoneinfo.patch;
zoneinfo = "${tzdata}/lib/${python.libPrefix}/site-packages/tzdata/zoneinfo";
})
];
propagatedBuildInputs = [
tzdata
] ++ lib.optionals (pythonOlder "3.7") [
importlib-resources importlib-resources
]; ];
@ -27,8 +40,14 @@ buildPythonPackage rec {
pytestCheckHook pytestCheckHook
]; ];
# unfortunately /etc/zoneinfo doesn't exist in sandbox, and many tests fail disabledTests = [
doCheck = false; # AssertionError: 'AEDT' != 'AEST'
"test_folds_and_gaps"
# AssertionError: 0 != 1 : (datetime.datetime(1917, 3, 25, 2, 0, 1, tzinfo=backports.zoneinfo.ZoneInfo(key='Australia/Sydney')), datetime.datetime(1917, 3, 24, 15, 0, tzinfo=datetime.timezone.utc))
"test_folds_from_utc"
# backports.zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Eurasia/Badzone'
"test_bad_keys"
];
meta = with lib; { meta = with lib; {
description = "Backport of the standard library module zoneinfo"; description = "Backport of the standard library module zoneinfo";

View file

@ -0,0 +1,17 @@
diff --git a/src/backports/zoneinfo/_tzpath.py b/src/backports/zoneinfo/_tzpath.py
index 9baaf6b..3f842af 100644
--- a/src/backports/zoneinfo/_tzpath.py
+++ b/src/backports/zoneinfo/_tzpath.py
@@ -24,10 +24,7 @@ def reset_tzpath(to=None):
base_tzpath = _parse_python_tzpath(env_var)
elif sys.platform != "win32":
base_tzpath = [
- "/usr/share/zoneinfo",
- "/usr/lib/zoneinfo",
- "/usr/share/lib/zoneinfo",
- "/etc/zoneinfo",
+ "@zoneinfo@"
]
base_tzpath.sort(key=lambda x: not os.path.exists(x))