njsmith / colorspacious

A powerful, accurate, and easy-to-use Python library for doing colorspace conversions
MIT License
169 stars 16 forks source link

building with python3 fails due to unhandled Unicode characters in README.rst #6

Closed rathann closed 7 years ago

rathann commented 8 years ago

When building colorspacious-1.0.0 using python-3.5.2, I get the following traceback:

/usr/bin/python3 setup.py build
Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    LONG_DESC = open("README.rst").read()
  File "/usr/lib64/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2025: ordinal not in range(128)

Here's one way of fixing this that works with both python2 and python3:

diff -up colorspacious-1.0.0/setup.py.orig colorspacious-1.0.0/setup.py
--- colorspacious-1.0.0/setup.py.orig   2015-07-03 23:59:00.000000000 +0200
+++ colorspacious-1.0.0/setup.py    2016-09-11 01:34:36.814624697 +0200
@@ -8,7 +8,11 @@ import numpy as np
 DESC = ("A powerful, accurate, and easy-to-use Python library for "
         "doing colorspace conversions")

-LONG_DESC = open("README.rst").read()
+try:
+    LONG_DESC = open("README.rst", encoding="utf-8").read()
+except (TypeError):
+    import codecs
+    LONG_DESC = codecs.open("README.rst", encoding="utf-8").read()

 # defines __version__
 exec(open("colorspacious/version.py").read())
QuLogic commented 7 years ago

How about:

with open('README.rst', 'rb') as f:
    LONG_DESC = f.read().decode('utf-8')

?

rathann commented 7 years ago

That works just as well, thanks.