[python-cheetah/f14/master] fix Cheetah to work with Python 2.7

Mike Bonnet mikeb at fedoraproject.org
Mon Oct 18 19:32:10 UTC 2010


commit 0fea0dfaf4d5a6cfe946fa0a5187ba91c1eb94dc
Author: Mike Bonnet <mikeb at redhat.com>
Date:   Mon Oct 18 15:31:56 2010 -0400

    fix Cheetah to work with Python 2.7

 cheetah-2.4-avoid-setuptools-warning.patch |   10 +++++++
 cheetah-2.4-python2.7-compat.patch         |   36 ++++++++++++++++++++++++++++
 cheetah-2.4-test-retcode.patch             |   13 ++++++++++
 python-cheetah.spec                        |   14 +++++++++-
 4 files changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/cheetah-2.4-avoid-setuptools-warning.patch b/cheetah-2.4-avoid-setuptools-warning.patch
new file mode 100644
index 0000000..067d433
--- /dev/null
+++ b/cheetah-2.4-avoid-setuptools-warning.patch
@@ -0,0 +1,10 @@
+diff -uNr Cheetah-2.4.2.1.orig/SetupConfig.py Cheetah-2.4.2.1/SetupConfig.py
+--- Cheetah-2.4.2.1.orig/SetupConfig.py	2010-02-07 23:17:23.000000000 -0500
++++ Cheetah-2.4.2.1/SetupConfig.py	2010-10-15 17:51:09.128340922 -0400
+@@ -29,6 +29,7 @@
+   Topic :: Software Development :: Libraries :: Python Modules
+   Topic :: Software Development :: User Interfaces
+   Topic :: Text Processing'''.splitlines() if not line.strip().startswith('#')]
++del line
+ 
+ package_dir = {'Cheetah':'cheetah'}
diff --git a/cheetah-2.4-python2.7-compat.patch b/cheetah-2.4-python2.7-compat.patch
new file mode 100644
index 0000000..c455c73
--- /dev/null
+++ b/cheetah-2.4-python2.7-compat.patch
@@ -0,0 +1,36 @@
+diff -uNr Cheetah-2.4.2.1.orig/cheetah/Template.py Cheetah-2.4.2.1/cheetah/Template.py
+--- Cheetah-2.4.2.1.orig/cheetah/Template.py	2010-02-07 23:17:23.000000000 -0500
++++ Cheetah-2.4.2.1/cheetah/Template.py	2010-10-18 14:06:54.439935114 -0400
+@@ -32,7 +32,7 @@
+ 
+ filetype = None
+ 
+-if isinstance(sys.version_info, tuple):
++if isinstance(sys.version_info[:], tuple):
+     # Python 2.xx
+     filetype = types.FileType
+     def createMethod(func, cls):
+diff -uNr Cheetah-2.4.2.1.orig/cheetah/Tests/SyntaxAndOutput.py Cheetah-2.4.2.1/cheetah/Tests/SyntaxAndOutput.py
+--- Cheetah-2.4.2.1.orig/cheetah/Tests/SyntaxAndOutput.py	2010-10-18 15:00:44.668935001 -0400
++++ Cheetah-2.4.2.1/cheetah/Tests/SyntaxAndOutput.py	2010-10-18 14:43:56.500934997 -0400
+@@ -847,17 +847,17 @@
+     def test10(self):
+         r"""func placeholder - with ('''\nstring\n''')"""
+         self.verify("$aFunc('''\naoeu\n''')",
+-                    "\naoeu\n")
++                    "\naoeu\n", convertEOLs=False)
+ 
+     def test11(self):
+         r"""func placeholder - with ('''\nstring'\n''')"""
+         self.verify("$aFunc('''\naoeu'\n''')",
+-                    "\naoeu'\n")
++                    "\naoeu'\n", convertEOLs=False)
+ 
+     def test12(self):
+         r'''func placeholder - with ("""\nstring\n""")'''
+         self.verify('$aFunc("""\naoeu\n""")',
+-                    "\naoeu\n")
++                    "\naoeu\n", convertEOLs=False)
+ 
+     def test13(self):
+         """func placeholder - with (string*int)"""
diff --git a/cheetah-2.4-test-retcode.patch b/cheetah-2.4-test-retcode.patch
new file mode 100644
index 0000000..072070d
--- /dev/null
+++ b/cheetah-2.4-test-retcode.patch
@@ -0,0 +1,13 @@
+diff -uNr Cheetah-2.4.2.1.orig/cheetah/CheetahWrapper.py Cheetah-2.4.2.1/cheetah/CheetahWrapper.py
+--- Cheetah-2.4.2.1.orig/cheetah/CheetahWrapper.py	2010-01-03 17:13:06.000000000 -0500
++++ Cheetah-2.4.2.1/cheetah/CheetahWrapper.py	2010-10-18 14:59:44.722934490 -0400
+@@ -263,7 +263,8 @@
+         if '-v' in self.testOpts:
+             verbosity = 2
+         runner = unittest.TextTestRunner(verbosity=verbosity)
+-        runner.run(unittest.TestSuite(Test.suites))
++        results = runner.run(unittest.TestSuite(Test.suites))
++        sys.exit(int(not results.wasSuccessful()))
+         
+     def version(self):
+         print(Version)
diff --git a/python-cheetah.spec b/python-cheetah.spec
index cdfd773..38d5455 100644
--- a/python-cheetah.spec
+++ b/python-cheetah.spec
@@ -2,7 +2,7 @@
 
 Name:           python-cheetah
 Version:        2.4.2.1
-Release:        2%{?dist}
+Release:        3%{?dist}
 Summary:        Template engine and code generator
 
 Group:          Development/Libraries
@@ -10,6 +10,10 @@ License:        MIT
 URL:            http://cheetahtemplate.org/
 Source:         http://pypi.python.org/packages/source/C/Cheetah/Cheetah-%{version}.tar.gz
 
+Patch0:         cheetah-2.4-python2.7-compat.patch
+Patch1:         cheetah-2.4-test-retcode.patch
+Patch2:         cheetah-2.4-avoid-setuptools-warning.patch
+
 BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 
 BuildRequires: python
@@ -30,6 +34,9 @@ code, Java, sql, form emails and even Python code.
 
 %prep
 %setup -q -n Cheetah-%{version}
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 # remove unnecessary shebang lines to silence rpmlint
 %{__sed} -i -e '/^#!/,1d' cheetah/Tests/* \
 	 cheetah/DirectiveAnalyzer.py cheetah/Utils/Misc.py
@@ -44,7 +51,7 @@ rm -rf %{buildroot}
 %check
 export PATH="%{buildroot}/%{_bindir}:$PATH"
 export PYTHONPATH="%{buildroot}/%{python_sitearch}"
-%{__python} %{buildroot}/%{python_sitearch}/Cheetah/Tests/Test.py
+%{buildroot}/%{_bindir}/cheetah test
 
 %clean
 rm -rf %{buildroot}
@@ -83,6 +90,9 @@ rm -rf %{buildroot}
 %{python_sitearch}/Cheetah-%{version}-*.egg-info/*.txt
 
 %changelog
+* Mon Oct 18 2010 Mike Bonnet <mikeb at redhat.com> - 2.4.2.1-3
+- Fix compatibility with Python 2.7
+
 * Wed Jul 21 2010 David Malcolm <dmalcolm at redhat.com> - 2.4.2.1-2
 - Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
 


More information about the scm-commits mailing list