diff --git a/pkgs/development/python-modules/backports-zoneinfo/default.nix b/pkgs/development/python-modules/backports-zoneinfo/default.nix index a9bc0b55955b..0b4703e26516 100644 --- a/pkgs/development/python-modules/backports-zoneinfo/default.nix +++ b/pkgs/development/python-modules/backports-zoneinfo/default.nix @@ -1,6 +1,9 @@ { lib, buildPythonPackage, fetchFromGitHub , pythonOlder +, python +, substituteAll , importlib-resources +, tzdata , hypothesis , pytestCheckHook }: @@ -16,7 +19,17 @@ buildPythonPackage rec { 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 ]; @@ -27,8 +40,14 @@ buildPythonPackage rec { pytestCheckHook ]; - # unfortunately /etc/zoneinfo doesn't exist in sandbox, and many tests fail - doCheck = false; + disabledTests = [ + # 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; { description = "Backport of the standard library module zoneinfo"; diff --git a/pkgs/development/python-modules/backports-zoneinfo/zoneinfo.patch b/pkgs/development/python-modules/backports-zoneinfo/zoneinfo.patch new file mode 100644 index 000000000000..69dd75030ab2 --- /dev/null +++ b/pkgs/development/python-modules/backports-zoneinfo/zoneinfo.patch @@ -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)) +