Update setup.py: Use io.open()
@@ -6,6 +6,8 @@ from __future__ import unicode_literals
import sys
import os
+from io import open
+
from setuptools import setup
from pattern import __version__
@@ -14,10 +16,11 @@ from pattern import __version__
# "python setup.py zip" will create the zipped distribution and checksum.
if sys.argv[-1] == "zip":
+
import zipfile
import hashlib
- import codecs
import re
+
n = "pattern-%s.zip" % __version__
p = os.path.join(os.path.dirname(os.path.realpath(__file__)))
z = zipfile.ZipFile(os.path.join(p, "..", n), "w", zipfile.ZIP_DEFLATED)
@@ -27,8 +30,8 @@ if sys.argv[-1] == "zip":
# Exclude private settings.
if f.endswith(os.path.join("web", "api.py")):
d = "#--- PRIVATE"
- s = codecs.open(f, "r", encoding="utf-8").read().split(d)
- x = codecs.open(f, "w", encoding="utf-8")
+ s = open(f, "r", encoding="utf-8").read().split(d)
+ x = open(f, "w", encoding="utf-8")
x.write(s[0])
x.close()
# Exclude revision history (.git).
@@ -36,7 +39,7 @@ if sys.argv[-1] == "zip":
if not re.search(r"\.DS|\.git[^i]|\.pyc|\.dev|tmp", f):
z.write(f, os.path.join("pattern-" + __version__, os.path.relpath(f, p)))
if f.endswith(os.path.join("web", "api.py")):
- x = codecs.open(f, "w", encoding="utf-8")
+ x = open(f, "w", encoding="utf-8")
x.write(d.join(s))
x.close()
z.close()
