Skip to content

setup.py: Add codecs and locale hacks #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ First release

#. versioning is applied
#. Pipfile included
#. codec and locale hacks added
1 change: 1 addition & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ releases:
details:
- versioning is applied
- Pipfile included
- codec and locale hacks added
date: 05.11.2018
version: 0.0.1

22 changes: 22 additions & 0 deletions templates/setup.py.jj2
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,30 @@ from platform import python_implementation
{%block compat_block%}
PY2 = sys.version_info[0] == 2
PY26 = PY2 and sys.version_info[1] < 7
PY33 = sys.version_info < (3, 4)
{%endblock%}

# Work around mbcs bug in distutils.
# http://bugs.python.org/issue10945
# This work around is only if a project supports Python < 3.4
{% if PY33 %}
try:
codecs.lookup('mbcs')
except LookupError:
ascii = codecs.lookup('ascii')
func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
codecs.register(func)
{% endif %}

# Work around for locale not being set
try:
lc = locale.getlocale()
pf = platform.system()
if pf != 'Windows' and lc == (None, None):
locale.setlocale(locale.LC_ALL, 'C.UTF-8')
except (ValueError, UnicodeError, locale.Error):
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')

NAME = '{{name}}'
AUTHOR = '{{author}}'
VERSION = '{{current_version}}'
Expand Down