summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2014-07-19 19:09:26 +0800
committerYu-Jie Lin <livibetter@gmail.com>2014-07-19 19:09:26 +0800
commitc508c11acef1930a956866fc259fc2b4bc43a732 (patch)
tree75e93826100cfe1ef479794b05d1af33d6719150
parent4c09fa8edab844786009d40ca6428abab60f445a (diff)
downloadsmartypants-git-c508c11acef1930a956866fc259fc2b4bc43a732.tar.gz
fix #5 UnicodeDecodeError when runs setup.py in Python 3 with special locale
Makefile is updated to also test this issue using LC_ALL=3. The invocation of virtualenv is changed to simplify.
-rw-r--r--CHANGES.rst10
-rw-r--r--Makefile25
-rwxr-xr-xsetup.py5
3 files changed, 24 insertions, 16 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index c2fea5b..c702493 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -58,6 +58,16 @@ Release 2.0.0
Development
-----------
+* Makefile
+
+ + add ``LC_ALL=C`` test for locale setting on ``setup.py`` wrt #5
+ * change virtualenv invocation method in ``install_test`` target
+
+* fix UnicodeDecodeError on opening ``smartypants.py``, which includes Unicode
+ characters, when running ``setup.py`` with Python 3 and specific locales
+ (#5, patch by BenoƮt Monin)
+
+
Release 1.8.5: 2014-07-03T01:56:03Z
-----------------------------------
diff --git a/Makefile b/Makefile
index ff41868..fcdaac9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2013 Yu-Jie Lin
+# Copyright (c) 2013, 2014 Yu-Jie Lin
# Licensed under the BSD License, for detailed license information, see COPYING
PACKAGE=smartypants
@@ -7,11 +7,6 @@ SCRIPT=smartypants
PY2_CMD=python2
PY3_CMD=python3
INSTALL_TEST_DIR=/tmp/$(PACKAGE)_install_test
-# if version or naming isn't matched to environment, for example, Python 2.6,
-# run the following to override:
-# make VENV_PY2_CMD=virtualenv-python2.6 install_test
-VENV_PY2_CMD=virtualenv-python2.7
-VENV_PY3_CMD=virtualenv-python3.2
BUILD_CMD=./setup.py sdist --formats gztar,zip bdist_wheel bdist_wininst --plat-name win32
@@ -66,20 +61,22 @@ test_doc8:
@echo '========================================================================================='
doc8 $(filter %.rst,$(DOC_FILES))
-install_test: $(VENV_PY2_CMD) $(VENV_PY3_CMD)
+install_test: install_test_$(PY2_CMD) install_test_$(PY3_CMD)
-$(VENV_PY2_CMD) $(VENV_PY3_CMD):
+install_test_$(PY2_CMD) install_test_$(PY3_CMD):
@echo '========================================================================================='
rm -rf $(INSTALL_TEST_DIR)
- $@ $(INSTALL_TEST_DIR)
- ./setup.py sdist --dist-dir $(INSTALL_TEST_DIR)
+ $(eval PY_CMD = $(subst install_test_,,$@))
+ $(PY_CMD) -m virtualenv $(INSTALL_TEST_DIR)
+ LC_ALL=C $(PY_CMD) setup.py --version >/dev/null
+ $(PY_CMD) setup.py sdist --dist-dir $(INSTALL_TEST_DIR)
$(INSTALL_TEST_DIR)/bin/pip install $(INSTALL_TEST_DIR)/*.tar.gz
@\
- CHK_VER="`$(PY2_CMD) $(SCRIPT) --version 2>&1`";\
+ CHK_VER="`$(PY_CMD) $(SCRIPT) --version 2>&1`";\
cd $(INSTALL_TEST_DIR);\
. bin/activate;\
- [ "`type $(SCRIPT)`" = "$(SCRIPT) is $(INSTALL_TEST_DIR)/bin/$(SCRIPT)" ];\
- [ "$$CHK_VER" = "`bin/$(SCRIPT) --version 2>&1`" ];\
+ [ "`type $(SCRIPT)`" = "$(SCRIPT) is $(INSTALL_TEST_DIR)/bin/$(SCRIPT)" ] &&\
+ [ "$$CHK_VER" = "`bin/$(SCRIPT) --version 2>&1`" ] &&\
[ "`echo '"foobar"' | bin/$(SCRIPT)`" = '&#8220;foobar&#8221;' ]
rm -rf $(INSTALL_TEST_DIR)
@@ -92,4 +89,4 @@ clean:
# ============================================================================
-.PHONY: build upload doc install_test $(VENV_PY2_CMD) $(VENV_PY3_CMD) clean
+.PHONY: build upload doc install_test install_test_$(PY2_CMD) install_test_$(PY3_CMD) clean
diff --git a/setup.py b/setup.py
index 3347249..7f3775d 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@
from __future__ import print_function
+import codecs
import sys
from distutils.core import Command, setup
from unittest import TestLoader, TextTestRunner
@@ -257,7 +258,7 @@ class cmd_pylint(Command):
# ============================================================================
-with open(module_file) as f:
+with codecs.open(module_file, encoding='utf-8') as f:
meta = dict(
(k.strip(' _'), eval(v)) for k, v in
# There will be a '\n', with eval(), it's safe to ignore
@@ -269,7 +270,7 @@ with open(module_file) as f:
'author_email']
meta = dict([m for m in meta.items() if m[0] in meta_keys])
-with open('README.rst') as f:
+with codecs.open('README.rst', encoding='utf-8') as f:
long_description = f.read()
classifiers = [