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 60f3c14 commit 29b6805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pybktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

__all__ = ['hamming_distance', 'BKTree']

__version__ = '1.0'
__version__ = '1.1'

_getitem0 = itemgetter(0)

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__), 'pybktree.py')) as f:
with open(os.path.join(os.path.dirname(__file__), 'pybktree.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 29b6805

Please sign in to comment.