Showing 1 of 3 files from the diff.
Other files ignored by Codecov

@@ -3,7 +3,7 @@
Loading
3 3
import tempfile
4 4
import shutil
5 5
import json
6 -
from subprocess import check_call
6 +
from subprocess import check_call, check_output
7 7
from tarfile import TarFile
8 8
9 9
from dateutil.zoneinfo import METADATA_FN, ZONEFILENAME
@@ -23,11 +23,9 @@
Loading
23 23
            for name in zonegroups:
24 24
                tf.extract(name, tmpdir)
25 25
            filepaths = [os.path.join(tmpdir, n) for n in zonegroups]
26 -
            try:
27 -
                check_call(["zic", "-d", zonedir] + filepaths)
28 -
            except OSError as e:
29 -
                _print_on_nosuchfile(e)
30 -
                raise
26 +
27 +
            _run_zic(zonedir, filepaths)
28 +
31 29
        # write metadata file
32 30
        with open(os.path.join(zonedir, METADATA_FN), 'w') as f:
33 31
            json.dump(metadata, f, indent=4, sort_keys=True)
@@ -40,6 +38,30 @@
Loading
40 38
        shutil.rmtree(tmpdir)
41 39
42 40
41 +
def _run_zic(zonedir, filepaths):
42 +
    """Calls the ``zic`` compiler in a compatible way to get a "fat" binary.
43 +
44 +
    Recent versions of ``zic`` default to ``-b slim``, while older versions
45 +
    don't even have the ``-b`` option (but default to "fat" binaries). The
46 +
    current version of dateutil does not support Version 2+ TZif files, which
47 +
    causes problems when used in conjunction with "slim" binaries, so this
48 +
    function is used to ensure that we always get a "fat" binary.
49 +
    """
50 +
51 +
    try:
52 +
        help_text = check_output(["zic", "--help"])
53 +
    except OSError as e:
54 +
        _print_on_nosuchfile(e)
55 +
        raise
56 +
57 +
    if b"-b " in help_text:
58 +
        bloat_args = ["-b", "fat"]
59 +
    else:
60 +
        bloat_args = []
61 +
62 +
    check_call(["zic"] + bloat_args + ["-d", zonedir] + filepaths)
63 +
64 +
43 65
def _print_on_nosuchfile(e):
44 66
    """Print helpful troubleshooting message
45 67
Files Coverage
dateutil 95.93%
Project Totals (32 files) 95.93%
2272.3
TRAVIS_PYTHON_VERSION=3.5
TRAVIS_OS_NAME=linux
TOXENV=py
2268.5
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py
2267.6
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py
2267.11
TRAVIS_PYTHON_VERSION=nightly
TRAVIS_OS_NAME=linux
TOXENV=py
2268.1
TRAVIS_PYTHON_VERSION=2.7
TRAVIS_OS_NAME=linux
TOXENV=py
2268.4
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py
2267.1
TRAVIS_PYTHON_VERSION=2.7
TRAVIS_OS_NAME=linux
TOXENV=py
2267.2
TRAVIS_PYTHON_VERSION=3.4
TRAVIS_OS_NAME=linux
TOXENV=py
2267.5
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py
2267.3
TRAVIS_PYTHON_VERSION=3.5
TRAVIS_OS_NAME=linux
TOXENV=py
2272.6
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=py
2272.11
TRAVIS_PYTHON_VERSION=nightly
TRAVIS_OS_NAME=linux
TOXENV=py
2268.2
TRAVIS_PYTHON_VERSION=3.4
TRAVIS_OS_NAME=linux
TOXENV=py
2272.5
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=py
2272.2
TRAVIS_PYTHON_VERSION=3.4
TRAVIS_OS_NAME=linux
TOXENV=py
2272.4
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py
2258.1
TRAVIS_PYTHON_VERSION=2.7
TRAVIS_OS_NAME=linux
TOXENV=py
8h6qu3v1t7nq2v10
TOXENV=py27
2258.2
TRAVIS_PYTHON_VERSION=3.4
TRAVIS_OS_NAME=linux
TOXENV=py
2258.4
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=py
2258.3
TRAVIS_PYTHON_VERSION=3.5
TRAVIS_OS_NAME=linux
TOXENV=py