Skip to content

Commit

Permalink
Fix encoding issue with README.rst/setup.py on Python 3 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Hoyt committed Aug 22, 2017
1 parent d08463c commit 808a57d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dhash.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
PIL = None


__version__ = '1.1'
__version__ = '1.2'

IS_PY3 = sys.version_info.major >= 3

Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

import os
import re
import sys
from distutils.core import setup


# Read files as byte strings on Python 2.x, unicode strings on 3.x
if sys.version_info < (3, 0):
open_args = {}
else:
open_args = {'encoding': 'utf-8'}


# Because it's best not to import the module in setup.py
with open(os.path.join(os.path.dirname(__file__), 'dhash.py')) as f:
with open(os.path.join(os.path.dirname(__file__), 'dhash.py'), **open_args) as f:
for line in f:
match = re.match(r"__version__.*'([0-9.]+)'", line)
if match:
Expand All @@ -17,7 +25,7 @@


# Read long_description from README.rst
with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
with open(os.path.join(os.path.dirname(__file__), 'README.rst'), **open_args) as f:
long_description = f.read()


Expand Down

0 comments on commit 808a57d

Please sign in to comment.