From a847ab59b0af8a62b0ef6296f63546caa44a9a9d Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Wed, 2 Jul 2014 18:40:39 +0200 Subject: [PATCH] New package: python-dateutil-2.2 Extensions to the standard Python datetime module. Add patch to use system zoneinfo, via Fedora. --- .../patches/use-system-zoneinfo.patch | 74 +++++++++++++++++++ srcpkgs/python-dateutil/template | 32 ++++++++ srcpkgs/python3.4-dateutil | 1 + 3 files changed, 107 insertions(+) create mode 100644 srcpkgs/python-dateutil/patches/use-system-zoneinfo.patch create mode 100644 srcpkgs/python-dateutil/template create mode 120000 srcpkgs/python3.4-dateutil diff --git a/srcpkgs/python-dateutil/patches/use-system-zoneinfo.patch b/srcpkgs/python-dateutil/patches/use-system-zoneinfo.patch new file mode 100644 index 00000000000..28cb21ab300 --- /dev/null +++ b/srcpkgs/python-dateutil/patches/use-system-zoneinfo.patch @@ -0,0 +1,74 @@ +diff -up dateutil/zoneinfo/__init__.py\~ dateutil/zoneinfo/__init__.py +--- dateutil/zoneinfo/__init__.py~ 2005-12-22 19:13:50.000000000 +0100 ++++ dateutil/zoneinfo/__init__.py 2011-08-17 15:24:29.019214748 +0200 +@@ -15,6 +15,7 @@ __all__ = ["setcachesize", "gettz", "reb + + CACHE = [] + CACHESIZE = 10 ++USE_SYSTEM_ZONEINFO = True # XXX configure at build time + + class tzfile(tzfile): + def __reduce__(self): +@@ -29,7 +30,8 @@ def getzoneinfofile(): + return os.path.join(os.path.dirname(__file__), entry) + return None + +-ZONEINFOFILE = getzoneinfofile() ++ZONEINFOFILE = getzoneinfofile() if USE_SYSTEM_ZONEINFO else None ++ZONEINFODIR = (os.getenv("TZDIR") or "/usr/share/zoneinfo").rstrip(os.sep) + + del getzoneinfofile + +@@ -39,22 +40,37 @@ def setcachesize(size): + del CACHE[size:] + + def gettz(name): +- tzinfo = None +- if ZONEINFOFILE: +- for cachedname, tzinfo in CACHE: +- if cachedname == name: +- break ++ for cachedname, tzinfo in CACHE: ++ if cachedname == name: ++ return tzinfo ++ ++ name_parts = name.lstrip('/').split('/') ++ for part in name_parts: ++ if part == os.path.pardir or os.path.sep in part: ++ raise ValueError('Bad path segment: %r' % part) ++ filename = os.path.join(ZONEINFODIR, *name_parts) ++ try: ++ zonefile = open(filename, "rb") ++ except: ++ tzinfo = None ++ else: ++ tzinfo = tzfile(zonefile) ++ zonefile.close() ++ ++ if tzinfo is None and ZONEINFOFILE: ++ tf = TarFile.open(ZONEINFOFILE) ++ try: ++ zonefile = tf.extractfile(name) ++ except KeyError: ++ tzinfo = None + else: +- tf = TarFile.open(ZONEINFOFILE) +- try: +- zonefile = tf.extractfile(name) +- except KeyError: +- tzinfo = None +- else: +- tzinfo = tzfile(zonefile) +- tf.close() +- CACHE.insert(0, (name, tzinfo)) +- del CACHE[CACHESIZE:] ++ tzinfo = tzfile(zonefile) ++ tf.close() ++ ++ if tzinfo is not None: ++ CACHE.insert(0, (name, tzinfo)) ++ del CACHE[CACHESIZE:] ++ + return tzinfo + + def rebuild(filename, tag=None, format="gz"): diff --git a/srcpkgs/python-dateutil/template b/srcpkgs/python-dateutil/template new file mode 100644 index 00000000000..bcfbc02de2f --- /dev/null +++ b/srcpkgs/python-dateutil/template @@ -0,0 +1,32 @@ +# Template file for 'python-dateutil' +pkgname=python-dateutil +version=2.2 +revision=1 +noarch=yes +build_style="python-module" +python_versions="2.7 3.4" +hostmakedepends="python-setuptools python3.4-setuptools" +makedepends="python-devel python3.4-devel python-six python3.4-six" +depends="python python-six tzdata" +pycompile_module="dateutil" +short_desc="Extensions to the standard Python2 datetime module" +maintainer="Alessio Sergi " +homepage="http://labix.org/python-dateutil/" +license="BSD" +distfiles="https://pypi.python.org/packages/source/p/${pkgname}/${pkgname}-${version}.tar.gz" +checksum=eec865307ebe7f329a6a9945c15453265a449cdaaf3710340828a1934d53e468 + +pre_build() { + sed -i -e '/package_data/d;/include_package_data/d' setup.py +} + +python3.4-dateutil_package() { + noarch=yes + depends="python3.4 python3.4-six tzdata" + pycompile_version="3.4" + pycompile_module="dateutil" + short_desc="${short_desc/Python2/Python3.4}" + pkg_install() { + vmove usr/lib/python3.4 + } +} diff --git a/srcpkgs/python3.4-dateutil b/srcpkgs/python3.4-dateutil new file mode 120000 index 00000000000..4ea05edb098 --- /dev/null +++ b/srcpkgs/python3.4-dateutil @@ -0,0 +1 @@ +python-dateutil \ No newline at end of file