From b7dcdf774a65c6832b36d737b3e9556c48ed750c Mon Sep 17 00:00:00 2001 From: Sascha Peilicke Date: Tue, 3 Sep 2013 13:48:38 +0200 Subject: [PATCH] Use codecs package and context manager for reading open(..., encoding=...) is only available with py3k, but the codecs package is around forever. This way we always end up with a unicode object holding the contents of either README.rst or LICENSE. Use a context manager (with keyword) for extra clean file descriptor closing. --- setup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ff1faf2..985318e 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,12 @@ """ """ from distutils.core import setup +import codecs + +with codecs.open('LICENSE', encoding="utf-8") as f: + license = f.read() +with codecs.open('README.rst', encoding="utf-8") as f: + long_description = f.read() setup( name='lesscpy', @@ -24,6 +30,6 @@ setup( 'lesscpy/test/css/issues/*.css', 'lesscpy/test/less/*.less', 'lesscpy/test/less/issues/*.less',]}, - license=open('LICENSE', encoding="utf-8").read(), - long_description=open('README.rst', encoding="utf-8").read(), + license=license, + long_description=long_description, )