From 8e0d5eaec84cffc991b8841f5b9df272f30437c3 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Wed, 23 Apr 2014 10:31:23 -0500 Subject: [PATCH] python < 2.6 does not have the 'with' statement --- setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 606a4e1..6993e1f 100644 --- a/setup.py +++ b/setup.py @@ -30,8 +30,12 @@ here = os.path.abspath(os.path.dirname(__file__)) def find_version(*file_paths): # Open in Latin-1 so that we avoid encoding errors. # Use codecs.open for Python 2 compatibility - with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f: + try: + f = codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') version_file = f.read() + f.close() + except: + raise RuntimeError("Unable to find version string.") # The version line must have the form # __version__ = 'ver' @@ -44,8 +48,9 @@ def find_version(*file_paths): # Get the long description from the relevant file try: - with codecs.open('README.rst', encoding='utf-8') as f: - long_description = f.read() + f = codecs.open('README.rst', encoding='utf-8') + long_description = f.read() + f.close() except: long_description = ''