[Python-modules-commits] [sphinx] 04/04: Update 0004-Extend-SOURCE_DATE_EPOCH-support.patch with test files

Dmitry Shachnev mitya57 at moszumanska.debian.org
Tue May 17 13:09:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch master
in repository sphinx.

commit eee8ebbfb68c1601a20a057a5227d5d75a817633
Merge: 2cad065 2980471
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Tue May 17 16:08:50 2016 +0300

    Update 0004-Extend-SOURCE_DATE_EPOCH-support.patch with test files

 debian/.git-dpm                                    |  4 +--
 .../0004-Extend-SOURCE_DATE_EPOCH-support.patch    | 35 ++++++++++++++++++----
 ...typing-private-API-change-in-Python-3.5.2.patch |  2 +-
 ...-compile_catalog-command-work-with-Babel-.patch |  2 +-
 tests/roots/test-correct-year/conf.py              |  3 ++
 tests/roots/test-correct-year/contents.rst         |  4 +++
 6 files changed, 40 insertions(+), 10 deletions(-)

diff --cc debian/.git-dpm
index 7be9894,0000000..c59176b
mode 100644,000000..100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@@ -1,11 -1,0 +1,11 @@@
 +# see git-dpm(1) from git-dpm package
- 0b587804de396b65cffc9b3f9c39a8cc6e6c7890
- 0b587804de396b65cffc9b3f9c39a8cc6e6c7890
++29804717e6cc9d90edfa22a2d49f15ed9664a00d
++29804717e6cc9d90edfa22a2d49f15ed9664a00d
 +6f627510ec8e2966f2f5f8081d7acb1a10de4b4f
 +6f627510ec8e2966f2f5f8081d7acb1a10de4b4f
 +sphinx_1.4.1.orig.tar.gz
 +d18b856710b22ae9740147e21754ca5b851af9b2
 +4259820
 +debianTag="debian/%e%v"
 +patchedTag="patched/%e%v"
 +upstreamTag="upstream/%e%u"
diff --cc debian/patches/0004-Extend-SOURCE_DATE_EPOCH-support.patch
index 9f44a4c,0000000..94a58ab
mode 100644,000000..100644
--- a/debian/patches/0004-Extend-SOURCE_DATE_EPOCH-support.patch
+++ b/debian/patches/0004-Extend-SOURCE_DATE_EPOCH-support.patch
@@@ -1,157 -1,0 +1,180 @@@
- From 0281df8904d5caaff3c42b908bd057f42e6731bb Mon Sep 17 00:00:00 2001
++From bbeef13a7d22a34cf6ef35197238e7b1e89ab530 Mon Sep 17 00:00:00 2001
 +From: =?UTF-8?q?Alexis=20Bienven=C3=BCe?= <pado at passoire.fr>
 +Date: Tue, 17 May 2016 14:28:48 +0300
 +Subject: Extend SOURCE_DATE_EPOCH support
 +
 +Taken from: https://github.com/sphinx-doc/sphinx/pull/2503
 +Fixes: https://bugs.debian.org/820895
 +---
-  sphinx/builders/gettext.py |  8 +++++++-
-  sphinx/config.py           | 13 +++++++++++-
-  sphinx/util/i18n.py        |  3 +--
-  tests/test_correct_year.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++
-  4 files changed, 69 insertions(+), 4 deletions(-)
++ sphinx/builders/gettext.py                 |  8 ++++-
++ sphinx/config.py                           | 13 +++++++-
++ sphinx/util/i18n.py                        |  3 +-
++ tests/roots/test-correct-year/conf.py      |  3 ++
++ tests/roots/test-correct-year/contents.rst |  4 +++
++ tests/test_correct_year.py                 | 49 ++++++++++++++++++++++++++++++
++ 6 files changed, 76 insertions(+), 4 deletions(-)
++ create mode 100644 tests/roots/test-correct-year/conf.py
++ create mode 100644 tests/roots/test-correct-year/contents.rst
 + create mode 100644 tests/test_correct_year.py
 +
 +diff --git a/sphinx/builders/gettext.py b/sphinx/builders/gettext.py
 +index fce6c8c..1c47893 100644
 +--- a/sphinx/builders/gettext.py
 ++++ b/sphinx/builders/gettext.py
 +@@ -11,7 +11,7 @@
 + 
 + from __future__ import unicode_literals
 + 
 +-from os import path, walk
 ++from os import path, walk, getenv
 + from codecs import open
 + from time import time
 + from datetime import datetime, tzinfo, timedelta
 +@@ -130,6 +130,12 @@ class I18nBuilder(Builder):
 + timestamp = time()
 + tzdelta = datetime.fromtimestamp(timestamp) - \
 +     datetime.utcfromtimestamp(timestamp)
 ++# set timestamp from SOURCE_DATE_EPOCH if set
 ++# see https://reproducible-builds.org/specs/source-date-epoch/
 ++source_date_epoch = getenv('SOURCE_DATE_EPOCH')
 ++if source_date_epoch is not None:
 ++    timestamp = float(source_date_epoch)
 ++    tzdelta = 0
 + 
 + 
 + class LocalTimeZone(tzinfo):
 +diff --git a/sphinx/config.py b/sphinx/config.py
 +index e199e7d..707f162 100644
 +--- a/sphinx/config.py
 ++++ b/sphinx/config.py
 +@@ -10,7 +10,7 @@
 + """
 + 
 + import re
 +-from os import path, environ
 ++from os import path, environ, getenv
 + import shlex
 + 
 + from six import PY2, PY3, iteritems, string_types, binary_type, text_type, integer_types
 +@@ -19,8 +19,10 @@ from sphinx.errors import ConfigError
 + from sphinx.locale import l_
 + from sphinx.util.osutil import make_filename, cd
 + from sphinx.util.pycompat import execfile_, NoneType
 ++from sphinx.util.i18n import format_date
 + 
 + nonascii_re = re.compile(br'[\x80-\xff]')
 ++copyright_year_re = re.compile(r'^((\d{4}-)?)(\d{4})(?=[ ,])')
 + 
 + CONFIG_SYNTAX_ERROR = "There is a syntax error in your configuration file: %s"
 + if PY3:
 +@@ -298,6 +300,15 @@ class Config(object):
 +         self.setup = config.get('setup', None)
 +         self.extensions = config.get('extensions', [])
 + 
 ++        # correct values of copyright year that are not coherent with
 ++        # the SOURCE_DATE_EPOCH environment variable (if set)
 ++        # See https://reproducible-builds.org/specs/source-date-epoch/
 ++        if getenv('SOURCE_DATE_EPOCH') is not None:
 ++            for k in ('copyright', 'epub_copyright'):
 ++                if k in config:
 ++                    config[k] = copyright_year_re.sub('\g<1>%s' % format_date('%Y'),
 ++                                                      config[k])
 ++
 +     def check_types(self, warn):
 +         # check all values for deviation from the default value's type, since
 +         # that can result in TypeErrors all over the place
 +diff --git a/sphinx/util/i18n.py b/sphinx/util/i18n.py
 +index f4a8bce..d0cb1f4 100644
 +--- a/sphinx/util/i18n.py
 ++++ b/sphinx/util/i18n.py
 +@@ -14,7 +14,6 @@ import os
 + import re
 + import warnings
 + from os import path
 +-from time import gmtime
 + from datetime import datetime
 + from collections import namedtuple
 + 
 +@@ -188,7 +187,7 @@ def format_date(format, date=None, language=None, warn=None):
 +         # See https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
 +         source_date_epoch = os.getenv('SOURCE_DATE_EPOCH')
 +         if source_date_epoch is not None:
 +-            date = gmtime(float(source_date_epoch))
 ++            date = datetime.utcfromtimestamp(float(source_date_epoch))
 +         else:
 +             date = datetime.now()
 + 
++diff --git a/tests/roots/test-correct-year/conf.py b/tests/roots/test-correct-year/conf.py
++new file mode 100644
++index 0000000..9b554aa
++--- /dev/null
+++++ b/tests/roots/test-correct-year/conf.py
++@@ -0,0 +1,3 @@
+++
+++copyright = u'2006-2009, Author'
+++
++diff --git a/tests/roots/test-correct-year/contents.rst b/tests/roots/test-correct-year/contents.rst
++new file mode 100644
++index 0000000..938dfd5
++--- /dev/null
+++++ b/tests/roots/test-correct-year/contents.rst
++@@ -0,0 +1,4 @@
+++=================
+++test-correct-year
+++=================
+++
 +diff --git a/tests/test_correct_year.py b/tests/test_correct_year.py
 +new file mode 100644
 +index 0000000..7a156cb
 +--- /dev/null
 ++++ b/tests/test_correct_year.py
 +@@ -0,0 +1,49 @@
 ++# -*- coding: utf-8 -*-
 ++"""
 ++    test_correct_year
 ++    ~~~~~~~~~~~~~~~~~
 ++
 ++    Test copyright year adjustment
 ++
 ++    :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
 ++    :license: BSD, see LICENSE for details.
 ++"""
 ++import os
 ++
 ++from util import TestApp
 ++
 ++
 ++def test_correct_year():
 ++    try:
 ++        # save current value of SOURCE_DATE_EPOCH
 ++        sde = os.environ.pop('SOURCE_DATE_EPOCH',None)
 ++
 ++        # test with SOURCE_DATE_EPOCH unset: no modification
 ++        app = TestApp(buildername='html',testroot='correct-year')
 ++        app.builder.build_all()
 ++        content = (app.outdir / 'contents.html').text()
 ++        app.cleanup()
 ++        assert '2006-2009' in content
 ++
 ++        # test with SOURCE_DATE_EPOCH set: copyright year should be
 ++        # updated
 ++        os.environ['SOURCE_DATE_EPOCH'] = "1293840000"
 ++        app = TestApp(buildername='html',testroot='correct-year')
 ++        app.builder.build_all()
 ++        content = (app.outdir / 'contents.html').text()
 ++        app.cleanup()
 ++        assert '2006-2011' in content
 ++
 ++        os.environ['SOURCE_DATE_EPOCH'] = "1293839999"
 ++        app = TestApp(buildername='html',testroot='correct-year')
 ++        app.builder.build_all()
 ++        content = (app.outdir / 'contents.html').text()
 ++        app.cleanup()
 ++        assert '2006-2010' in content
 ++
 ++    finally:
 ++        # Restores SOURCE_DATE_EPOCH
 ++        if sde == None:
 ++            os.environ.pop('SOURCE_DATE_EPOCH',None)
 ++        else:
 ++            os.environ['SOURCE_DATE_EPOCH'] = sde
diff --cc debian/patches/0005-Adapt-to-typing-private-API-change-in-Python-3.5.2.patch
index 426e22d,0000000..b495837
mode 100644,000000..100644
--- a/debian/patches/0005-Adapt-to-typing-private-API-change-in-Python-3.5.2.patch
+++ b/debian/patches/0005-Adapt-to-typing-private-API-change-in-Python-3.5.2.patch
@@@ -1,36 -1,0 +1,36 @@@
- From d390cb393bf8cff77963cc5592dee82b7c07b023 Mon Sep 17 00:00:00 2001
++From 5df9bd941bd36ecaf774490aca30e857d55168f0 Mon Sep 17 00:00:00 2001
 +From: Dmitry Shachnev <mitya57 at gmail.com>
 +Date: Sun, 8 May 2016 12:10:40 +0300
 +Subject: Adapt to typing private API change in Python 3.5.2
 +
 +Taken from: https://github.com/sphinx-doc/sphinx/pull/2532
 +Fixes: https://github.com/sphinx-doc/sphinx/issues/2519
 +---
 + sphinx/ext/autodoc.py | 14 +++++++++++---
 + 1 file changed, 11 insertions(+), 3 deletions(-)
 +
 +diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py
 +index 7dc89d3..e32511a 100644
 +--- a/sphinx/ext/autodoc.py
 ++++ b/sphinx/ext/autodoc.py
 +@@ -269,9 +269,17 @@ def format_annotation(annotation):
 +         if isinstance(annotation, typing.TypeVar):
 +             return annotation.__name__
 +         elif hasattr(typing, 'GenericMeta') and \
 +-                isinstance(annotation, typing.GenericMeta) and \
 +-                hasattr(annotation, '__parameters__'):
 +-            params = annotation.__parameters__
 ++                isinstance(annotation, typing.GenericMeta):
 ++            # In Python 3.5.2+, all arguments are stored in __args__,
 ++            # whereas __parameters__ only contains generic parameters.
 ++            #
 ++            # Prior to Python 3.5.2, __args__ is not available, and all
 ++            # arguments are in __parameters__.
 ++            params = None
 ++            if hasattr(annotation, '__args__'):
 ++                params = annotation.__args__
 ++            elif hasattr(annotation, '__parameters__'):
 ++                params = annotation.__parameters__
 +             if params is not None:
 +                 param_str = ', '.join(format_annotation(p) for p in params)
 +                 return '%s[%s]' % (qualified_name, param_str)
diff --cc debian/patches/0006-Make-custom-compile_catalog-command-work-with-Babel-.patch
index c930e24,0000000..1536a92
mode 100644,000000..100644
--- a/debian/patches/0006-Make-custom-compile_catalog-command-work-with-Babel-.patch
+++ b/debian/patches/0006-Make-custom-compile_catalog-command-work-with-Babel-.patch
@@@ -1,64 -1,0 +1,64 @@@
- From 0b587804de396b65cffc9b3f9c39a8cc6e6c7890 Mon Sep 17 00:00:00 2001
++From 29804717e6cc9d90edfa22a2d49f15ed9664a00d Mon Sep 17 00:00:00 2001
 +From: Dmitry Shachnev <mitya57 at gmail.com>
 +Date: Tue, 17 May 2016 15:43:59 +0300
 +Subject: Make custom compile_catalog command work with Babel 2.3
 +
 +In new Babel versions, self.domain is a list rather than a string.
 +
 +Taken from: https://github.com/sphinx-doc/sphinx/pull/2553
 +---
 + setup.py | 17 ++++++++++++-----
 + 1 file changed, 12 insertions(+), 5 deletions(-)
 +
 +diff --git a/setup.py b/setup.py
 +index 404d62b..f5bc056 100644
 +--- a/setup.py
 ++++ b/setup.py
 +@@ -96,6 +96,13 @@ else:
 +         def run(self):
 +             compile_catalog.run(self)
 + 
 ++            if isinstance(self.domain, list):
 ++                for domain in self.domain:
 ++                    self._run_domain_js(domain)
 ++            else:
 ++                self._run_domain_js(self.domain)
 ++
 ++        def _run_domain_js(self, domain):
 +             po_files = []
 +             js_files = []
 + 
 +@@ -104,20 +111,20 @@ else:
 +                     po_files.append((self.locale,
 +                                      os.path.join(self.directory, self.locale,
 +                                                   'LC_MESSAGES',
 +-                                                  self.domain + '.po')))
 ++                                                  domain + '.po')))
 +                     js_files.append(os.path.join(self.directory, self.locale,
 +                                                  'LC_MESSAGES',
 +-                                                 self.domain + '.js'))
 ++                                                 domain + '.js'))
 +                 else:
 +                     for locale in os.listdir(self.directory):
 +                         po_file = os.path.join(self.directory, locale,
 +                                                'LC_MESSAGES',
 +-                                               self.domain + '.po')
 ++                                               domain + '.po')
 +                         if os.path.exists(po_file):
 +                             po_files.append((locale, po_file))
 +                             js_files.append(os.path.join(self.directory, locale,
 +                                                          'LC_MESSAGES',
 +-                                                         self.domain + '.js'))
 ++                                                         domain + '.js'))
 +             else:
 +                 po_files.append((self.locale, self.input_file))
 +                 if self.output_file:
 +@@ -125,7 +132,7 @@ else:
 +                 else:
 +                     js_files.append(os.path.join(self.directory, self.locale,
 +                                                  'LC_MESSAGES',
 +-                                                 self.domain + '.js'))
 ++                                                 domain + '.js'))
 + 
 +             for js_file, (locale, po_file) in zip(js_files, po_files):
 +                 infile = open(po_file, 'r')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/sphinx.git



More information about the Python-modules-commits mailing list