python-pefile/pefile-fix-build-43c1cc79a71.patch

54 lines
1.8 KiB
Diff
Raw Normal View History

2016-11-01 20:15:16 +00:00
diff --git a/setup.py b/setup.py
2016-11-01 20:40:15 +00:00
index f5345bb..b932eb7 100755
2016-11-01 20:15:16 +00:00
--- a/setup.py
+++ b/setup.py
2016-11-01 20:40:15 +00:00
@@ -5,6 +5,9 @@ import os
2016-11-01 20:15:16 +00:00
import re
import sys
2016-11-01 20:40:15 +00:00
2016-11-01 20:15:16 +00:00
+if sys.version_info.major == 3:
+ from io import open
2016-11-01 20:40:15 +00:00
+
2016-11-01 20:15:16 +00:00
try:
from setuptools import setup, Command
2016-11-01 20:40:15 +00:00
except ImportError as excp:
@@ -22,8 +25,12 @@ def _read_doc():
2016-11-01 20:15:16 +00:00
Parse docstring from file 'pefile.py' and avoid importing
this module directly.
"""
2016-11-01 20:40:15 +00:00
- with open('pefile.py', 'r') as f:
- tree = ast.parse(f.read())
2016-11-01 20:15:16 +00:00
+ 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)
2016-11-01 20:40:15 +00:00
@@ -35,8 +42,12 @@ def _read_attr(attr_name):
2016-11-01 20:15:16 +00:00
__version__, __author__, __contact__,
"""
regex = attr_name + r"\s+=\s+'(.+)'"
2016-11-01 20:40:15 +00:00
- with open('pefile.py', 'r') as f:
2016-11-01 20:15:16 +00:00
- 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)
2016-11-01 20:40:15 +00:00
@@ -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',