public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/python-dateutil/, dev-python/python-dateutil/files/
Date: Fri, 20 Apr 2018 11:53:29 +0000 (UTC)	[thread overview]
Message-ID: <1524225092.19d591fa2356aab3456db0381747f7785ef8b7be.mgorny@gentoo> (raw)

commit:     19d591fa2356aab3456db0381747f7785ef8b7be
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 20 11:47:58 2018 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Apr 20 11:51:32 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=19d591fa

dev-python/python-dateutil: Use system tzdata correctly

Closes: https://bugs.gentoo.org/652226

 ...info-Get-timezone-data-from-system-tzdata.patch | 104 +++++++++++++++++++++
 .../python-dateutil-2.7.2-r1.ebuild                |  49 ++++++++++
 2 files changed, 153 insertions(+)

diff --git a/dev-python/python-dateutil/files/0001-zoneinfo-Get-timezone-data-from-system-tzdata.patch b/dev-python/python-dateutil/files/0001-zoneinfo-Get-timezone-data-from-system-tzdata.patch
new file mode 100644
index 00000000000..2e3f4ee914c
--- /dev/null
+++ b/dev-python/python-dateutil/files/0001-zoneinfo-Get-timezone-data-from-system-tzdata.patch
@@ -0,0 +1,104 @@
+From f48e70ae846c161dfbfe6ddb36e4bcad4427ac8c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
+Date: Tue, 3 Apr 2018 22:03:32 +0200
+Subject: [PATCH] zoneinfo: Get timezone data from system tzdata
+
+---
+ dateutil/test/test_imports.py |  3 +--
+ dateutil/zoneinfo/__init__.py | 25 ++++++++++++++-----------
+ 2 files changed, 15 insertions(+), 13 deletions(-)
+
+diff --git a/dateutil/test/test_imports.py b/dateutil/test/test_imports.py
+index 2a19b62..97d07e4 100644
+--- a/dateutil/test/test_imports.py
++++ b/dateutil/test/test_imports.py
+@@ -158,9 +158,8 @@ class ImportZoneInfoTest(unittest.TestCase):
+     def testZoneinfoStar(self):
+         from dateutil.zoneinfo import gettz
+         from dateutil.zoneinfo import gettz_db_metadata
+-        from dateutil.zoneinfo import rebuild
+ 
+-        zi_all = (gettz, gettz_db_metadata, rebuild)
++        zi_all = (gettz, gettz_db_metadata)
+ 
+         for var in zi_all:
+             self.assertIsNot(var, None)
+diff --git a/dateutil/zoneinfo/__init__.py b/dateutil/zoneinfo/__init__.py
+index 34f11ad..e9870ca 100644
+--- a/dateutil/zoneinfo/__init__.py
++++ b/dateutil/zoneinfo/__init__.py
+@@ -1,6 +1,7 @@
+ # -*- coding: utf-8 -*-
+ import warnings
+ import json
++import os
+ 
+ from tarfile import TarFile
+ from pkgutil import get_data
+@@ -10,7 +11,7 @@ from dateutil.tz import tzfile as _tzfile
+ 
+ __all__ = ["get_zonefile_instance", "gettz", "gettz_db_metadata"]
+ 
+-ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
++ZONEDIRECTORY = "/usr/share/zoneinfo"
+ METADATA_FN = 'METADATA'
+ 
+ 
+@@ -19,12 +20,14 @@ class tzfile(_tzfile):
+         return (gettz, (self._filename,))
+ 
+ 
+-def getzoneinfofile_stream():
+-    try:
+-        return BytesIO(get_data(__name__, ZONEFILENAME))
+-    except IOError as e:  # TODO  switch to FileNotFoundError?
+-        warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
+-        return None
++def iter_zones(topdir):
++    for dirpath, dirnames, filenames in os.walk(topdir):
++        for f in filenames:
++            if f.endswith('.tab'):
++                continue
++            fpath = os.path.join(dirpath, f)
++            relpath = os.path.relpath(fpath, topdir)
++            yield (relpath, tzfile(fpath, filename=relpath))
+ 
+ 
+ class ZoneInfoFile(object):
+@@ -48,7 +51,7 @@ class ZoneInfoFile(object):
+                     # no metadata in tar file
+                     self.metadata = None
+         else:
+-            self.zones = {}
++            self.zones = dict(iter_zones(ZONEDIRECTORY))
+             self.metadata = None
+ 
+     def get(self, name, default=None):
+@@ -99,7 +102,7 @@ def get_zonefile_instance(new_instance=False):
+         zif = getattr(get_zonefile_instance, '_cached_instance', None)
+ 
+     if zif is None:
+-        zif = ZoneInfoFile(getzoneinfofile_stream())
++        zif = ZoneInfoFile()
+ 
+         get_zonefile_instance._cached_instance = zif
+ 
+@@ -140,7 +143,7 @@ def gettz(name):
+                   DeprecationWarning)
+ 
+     if len(_CLASS_ZONE_INSTANCE) == 0:
+-        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
++        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile())
+     return _CLASS_ZONE_INSTANCE[0].zones.get(name)
+ 
+ 
+@@ -163,5 +166,5 @@ def gettz_db_metadata():
+                   DeprecationWarning)
+ 
+     if len(_CLASS_ZONE_INSTANCE) == 0:
+-        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile(getzoneinfofile_stream()))
++        _CLASS_ZONE_INSTANCE.append(ZoneInfoFile())
+     return _CLASS_ZONE_INSTANCE[0].metadata
+-- 
+2.17.0
+

diff --git a/dev-python/python-dateutil/python-dateutil-2.7.2-r1.ebuild b/dev-python/python-dateutil/python-dateutil-2.7.2-r1.ebuild
new file mode 100644
index 00000000000..3ce895de047
--- /dev/null
+++ b/dev-python/python-dateutil/python-dateutil-2.7.2-r1.ebuild
@@ -0,0 +1,49 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+PYTHON_COMPAT=( python2_7 python3_{4,5,6} pypy pypy3 )
+
+inherit distutils-r1
+
+DESCRIPTION="Extensions to the standard Python datetime module"
+HOMEPAGE="
+	https://dateutil.readthedocs.org/
+	https://pypi.org/project/python-dateutil
+	https://github.com/dateutil/dateutil/
+"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
+IUSE="test"
+
+RDEPEND="
+	>=dev-python/six-1.5[${PYTHON_USEDEP}]
+	sys-libs/timezone-data
+"
+DEPEND="${RDEPEND}
+	dev-python/setuptools_scm[${PYTHON_USEDEP}]
+	dev-python/setuptools[${PYTHON_USEDEP}]
+	test? (
+		dev-python/pytest[${PYTHON_USEDEP}]
+		dev-python/freezegun[${PYTHON_USEDEP}]
+	)
+"
+
+python_prepare_all() {
+	local PATCHES=(
+		"${FILESDIR}"/0001-zoneinfo-Get-timezone-data-from-system-tzdata.patch
+	)
+
+	# don't install zoneinfo tarball
+	sed -i '/package_data=/d' setup.py || die
+
+	distutils-r1_python_prepare_all
+}
+
+python_test() {
+	py.test -v || die "Tests failed under ${EPYTHON}"
+}


             reply	other threads:[~2018-04-20 11:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 11:53 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-11-22  0:20 [gentoo-commits] repo/gentoo:master commit in: dev-python/python-dateutil/, dev-python/python-dateutil/files/ Patrick McLean
2021-07-15  9:22 Michał Górny
2021-08-16  6:13 Michał Górny
2024-03-01 19:06 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524225092.19d591fa2356aab3456db0381747f7785ef8b7be.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox