From 484ce003db88bdfc48b4a3a3481f575c06781989 Mon Sep 17 00:00:00 2001 From: Tim Harder Date: Fri, 23 Aug 2019 03:18:39 -0600 Subject: [PATCH] utils: delay chardet import until it's used --- src/pkgcheck/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pkgcheck/utils.py b/src/pkgcheck/utils.py index cf92a29fe..32898fa61 100644 --- a/src/pkgcheck/utils.py +++ b/src/pkgcheck/utils.py @@ -1,6 +1,3 @@ -import chardet - - # based on https://github.com/audreyr/binaryornot # # Copyright (c) 2013, Audrey Roy @@ -86,6 +83,10 @@ def is_binary(path, blocksize=1024): byte_str.decode() decodable = True except UnicodeDecodeError: + # Delay import to hide during wheel/sdist builds that iterate over and + # import most modules to generate check/keyword/reporter lists. + import chardet + # guess character encoding using chardet detected_encoding = chardet.detect(byte_str) if detected_encoding['confidence'] > 0.8: