python < 2.6 does not have the 'with' statement
This commit is contained in:
parent
966fd2c86d
commit
8e0d5eaec8
11
setup.py
11
setup.py
|
@ -30,8 +30,12 @@ here = os.path.abspath(os.path.dirname(__file__))
|
||||||
def find_version(*file_paths):
|
def find_version(*file_paths):
|
||||||
# Open in Latin-1 so that we avoid encoding errors.
|
# Open in Latin-1 so that we avoid encoding errors.
|
||||||
# Use codecs.open for Python 2 compatibility
|
# 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()
|
version_file = f.read()
|
||||||
|
f.close()
|
||||||
|
except:
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
# The version line must have the form
|
# The version line must have the form
|
||||||
# __version__ = 'ver'
|
# __version__ = 'ver'
|
||||||
|
@ -44,8 +48,9 @@ def find_version(*file_paths):
|
||||||
|
|
||||||
# Get the long description from the relevant file
|
# Get the long description from the relevant file
|
||||||
try:
|
try:
|
||||||
with codecs.open('README.rst', encoding='utf-8') as f:
|
f = codecs.open('README.rst', encoding='utf-8')
|
||||||
long_description = f.read()
|
long_description = f.read()
|
||||||
|
f.close()
|
||||||
except:
|
except:
|
||||||
long_description = ''
|
long_description = ''
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue