diff --git a/setup.py b/setup.py index f5345bb..b932eb7 100755 --- a/setup.py +++ b/setup.py @@ -5,6 +5,9 @@ import os import re import sys +if sys.version_info.major == 3: + from io import open + try: from setuptools import setup, Command except ImportError as excp: @@ -22,8 +25,12 @@ def _read_doc(): Parse docstring from file 'pefile.py' and avoid importing this module directly. """ - with open('pefile.py', 'r') as f: - tree = ast.parse(f.read()) + if sys.version_info.major == 2: + with open('pefile.py', 'r') as f: + tree = ast.parse(f.read()) + else: + with open('pefile.py', 'r', encoding='utf-8') as f: + tree = ast.parse(f.read()) return ast.get_docstring(tree) @@ -35,8 +42,12 @@ def _read_attr(attr_name): __version__, __author__, __contact__, """ regex = attr_name + r"\s+=\s+'(.+)'" - with open('pefile.py', 'r') as f: - match = re.search(regex, f.read()) + if sys.version_info.major == 2: + with open('pefile.py', 'r') as f: + match = re.search(regex, f.read()) + else: + with open('pefile.py', 'r', encoding='utf-8') as f: + match = re.search(regex, f.read()) # Second item in the group is the value of attribute. return match.group(1) @@ -80,7 +91,7 @@ setup(name = 'pefile', author = _read_attr('__author__'), author_email = _read_attr('__contact__'), url = 'https://github.com/erocarrera/pefile', - download_url='https://github.com/erocarrera/pefile/releases/download/v2016.3.28/pefile-2016.3.28.tar.gz', + download_url='https://github.com/erocarrera/pefile/files/192316/pefile-2016.3.28.tar.gz', keywords = ['pe', 'exe', 'dll', 'pefile', 'pecoff'], classifiers = [ 'Development Status :: 5 - Production/Stable',