Commits

Walter Dörwald committed 459cced

Open __init__.py with the correct encoding in build_py.check_package() on Python 3.

Comments (0)

Files changed (1)

setuptools/command/build_py.py

-import os.path, sys, fnmatch
+import os.path, sys, fnmatch, tokenize
 from distutils.command.build_py import build_py as _build_py
 from distutils.util import convert_path
 from glob import glob
         else:
             return init_py
 
-        f = open(init_py,'rU')
+        if sys.version_info >= (3,):
+            # Open with the correct encoding
+            f = tokenize.open(init_py)
+        else:
+            f = open(init_py,'rU')
         if 'declare_namespace' not in f.read():
             from distutils import log
             log.warn(