GeospatialPython / pyshp

This library reads and writes ESRI Shapefiles in pure Python.
MIT License
1.1k stars 259 forks source link

Fix UnicodeDecodeError in setup.py. #171

Closed sebastic closed 5 years ago

sebastic commented 5 years ago

As mentioned in #169, setup.py fails to read the README.md due to an UnicodeDecodeError.

This is fixed by explicitly setting the encoding, and using the codecs library with Python 2.7.

megies commented 5 years ago

Although I couldn't reproduce the problem, I agree that explicit decoding is definitively the right thing to do here.

Personally, I'd avoid the Python 3 if/else, though and just explicitly decode:

with open('README.md', 'rb') as fh:
    data = fh.read()
data = data.decode('utf-8')
sebastic commented 5 years ago

Using decode works too, but since the with statement was added in Python 2.5 the interpreter version requirements should probably be documented in setup.py too.

megies commented 5 years ago

I agree, Python versions (2.7 and 3.x) should be specified in setup.py.

sebastic commented 5 years ago

python_requires has been added to setup.py, see:

https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires

karimbahgat commented 5 years ago

Looks good, thanks for the swift fix!