summaryrefslogtreecommitdiff
path: root/dev-python/pytz/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2023-03-25 18:50:52 +0000
committerV3n3RiX <venerix@koprulu.sector>2023-03-25 18:50:52 +0000
commite292b671b113c2cc012beddad93a3df4f9410698 (patch)
tree96b510d2f17600f87d69b1ad0edddee81cb7b791 /dev-python/pytz/files
parent71d582d27eeece574ab3d904aa3fbe7742b0e895 (diff)
gentoo auto-resync : 25:03:2023 - 18:50:52
Diffstat (limited to 'dev-python/pytz/files')
-rw-r--r--dev-python/pytz/files/pytz-2023.2-system-tzinfo.patch51
1 files changed, 51 insertions, 0 deletions
diff --git a/dev-python/pytz/files/pytz-2023.2-system-tzinfo.patch b/dev-python/pytz/files/pytz-2023.2-system-tzinfo.patch
new file mode 100644
index 000000000000..1e64f1bd2fa4
--- /dev/null
+++ b/dev-python/pytz/files/pytz-2023.2-system-tzinfo.patch
@@ -0,0 +1,51 @@
+Inspired by the Fedora patch:
+https://src.fedoraproject.org/rpms/pytz/blob/rawhide/f/pytz-zoneinfo.patch
+
+_allzones() is based on code in gen_tzinfo.py in upstream repo.
+
+diff --git a/pytz/__init__.py b/pytz/__init__.py
+index f89d0eb..d00f3bb 100644
+--- a/pytz/__init__.py
++++ b/pytz/__init__.py
+@@ -75,6 +75,20 @@ else: # Python 2.x
+ return s.encode('ASCII')
+
+
++def _allzones():
++ for dirpath, dirnames, filenames in os.walk(_PYTZ_TZDATADIR):
++ for f in filenames:
++ p = os.path.join(dirpath, f)
++ if open(p, 'rb').read(4) == b'TZif':
++ yield os.path.relpath(p, _PYTZ_TZDATADIR)
++
++
++_PYTZ_TZDATADIR = os.environ.get('PYTZ_TZDATADIR', '/usr/share/zoneinfo')
++_all_timezones_unchecked = LazyList(x for x in _allzones())
++all_timezones = _all_timezones_unchecked
++all_timezones_set = LazySet(all_timezones)
++
++
+ def open_resource(name):
+ """Open a resource from the zoneinfo subdir for reading.
+
+@@ -88,7 +102,7 @@ def open_resource(name):
+ for part in name_parts:
+ if part == os.path.pardir or os.sep in part:
+ raise ValueError('Bad path segment: %r' % part)
+- zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', None)
++ zoneinfo_dir = _PYTZ_TZDATADIR
+ if zoneinfo_dir is not None:
+ filename = os.path.join(zoneinfo_dir, *name_parts)
+ else:
+diff --git a/setup.py b/setup.py
+index 24f7f37..b03592c 100644
+--- a/setup.py
++++ b/setup.py
+@@ -21,7 +21,6 @@ for dirpath, dirnames, filenames in os.walk(os.path.join('pytz', 'zoneinfo')):
+ resources.extend([os.path.join(basepath, filename) for filename in filenames])
+ package_data = {'pytz': resources}
+
+-assert len(resources) > 10, 'zoneinfo files not found!'
+
+ setup(
+ name='pytz',