Skip to content

Commit

Permalink
Make setup.py work with python2.
Browse files Browse the repository at this point in the history
This is needed for distributions (Debian/Ubuntu) which only have a python2 tox.
Tests will still be run with python3, but the setup will be called with
python2.
  • Loading branch information
The-Compiler committed Mar 26, 2015
1 parent f518b5b commit 513fbb1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/setupcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))


if sys.hexversion >= 0x03000000:
_open = open
else:
import codecs
_open = codecs.open


BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
os.path.pardir)


def read_file(name):
"""Get the string contained in the file named name."""
with open(name, 'r', encoding='utf-8') as f:
with _open(name, 'r', encoding='utf-8') as f:
return f.read()


Expand Down Expand Up @@ -88,7 +95,7 @@ def write_git_file():
if gitstr is None:
gitstr = ''
path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id')
with open(path, 'w', encoding='utf-8') as f:
with _open(path, 'w', encoding='ascii') as f:
f.write(gitstr)


Expand Down

0 comments on commit 513fbb1

Please sign in to comment.