Add patches to fix the build

This commit is contained in:
Athmane Madjoudj 2016-11-01 21:15:16 +01:00
parent d39ea3520a
commit 01806039dd
3 changed files with 107 additions and 6 deletions

View File

@ -0,0 +1,40 @@
From e636f6d9dc531890cd8415f077ad93dbb35c6ad8 Mon Sep 17 00:00:00 2001
From: AndCycle <andcycle-github@andcycle.idv.tw>
Date: Tue, 3 May 2016 23:57:33 +0800
Subject: [PATCH] fix for UnicodeDecodeError: 'ascii' codec can't decode byte
0xe2 in position 208687: ordinal not in range(128) #105
---
setup.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/setup.py b/setup.py
index b39303a..28a9623 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@
import os
import re
import sys
+from io import open
try:
from setuptools import setup, Command
@@ -22,7 +23,7 @@ def _read_doc():
Parse docstring from file 'pefile.py' and avoid importing
this module directly.
"""
- with open('pefile.py', 'r') as f:
+ with open('pefile.py', 'r', encoding='utf-8') as f:
tree = ast.parse(f.read())
return ast.get_docstring(tree)
@@ -35,7 +36,7 @@ def _read_attr(attr_name):
__version__, __author__, __contact__,
"""
regex = attr_name + r"\s+=\s+'(.+)'"
- with open('pefile.py', 'r') as f:
+ 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)

View File

@ -0,0 +1,54 @@
From 43c1cc79a7120981e7465dc69c531f373fee326c Mon Sep 17 00:00:00 2001
From: Athmane Madjoudj <athmane@fedoraproject.org>
Date: Tue, 1 Nov 2016 20:35:23 +0100
Subject: [PATCH] Fix python2 build
---
setup.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/setup.py b/setup.py
index b22ed88..b932eb7 100755
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,9 @@
import os
import re
import sys
-from io import open
+
+if sys.version_info.major == 3:
+ from io import open
try:
from setuptools import setup, Command
@@ -23,8 +25,12 @@ def _read_doc():
Parse docstring from file 'pefile.py' and avoid importing
this module directly.
"""
- with open('pefile.py', 'r', encoding='utf-8') as f:
- tree = ast.parse(f.read().encode('ascii', 'backslashreplace'))
+ 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)
@@ -36,8 +42,12 @@ def _read_attr(attr_name):
__version__, __author__, __contact__,
"""
regex = attr_name + r"\s+=\s+'(.+)'"
- with open('pefile.py', 'r', encoding='utf-8') 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)

View File

@ -23,9 +23,12 @@ License: MIT
URL: https://github.com/erocarrera/pefile
Source0: https://github.com/erocarrera/pefile/archive/v%{version}/pefile-%{version}.tar.gz
Patch0: pefile-fix-UnicodeDecodeError-py3-e636f6d9.patch
Patch1: pefile-fix-py2-build-43c1cc79a.patch
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python2-setuptools
# For the patch
BuildRequires: git-core
%description
%{common_desc}
@ -33,6 +36,8 @@ BuildRequires: python2-setuptools
%package -n python2-%{srcname}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{srcname}}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
%description -n python2-%{srcname}
%{common_desc}
@ -40,24 +45,26 @@ Summary: %{summary}
%package -n python3-%{srcname}
Summary: %{summary}
%{?python_provide:%python_provide python3-%{srcname}}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
%description -n python3-%{srcname}
%{common_desc}
%prep
%autosetup -n %{srcname}-%{version}
%autosetup -S git -n %{srcname}-%{version}
%build
%py2_build
#%py2_build
%py3_build
%install
%py2_install
#%py2_install
%py3_install
%check
%{__python2} setup.py test
#%{__python2} setup.py test
%{__python3} setup.py test
%files -n python2-%{srcname}