Skip to content
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

Setup fails if default encoding != utf8 #127

Open
jajadinimueter opened this issue Sep 16, 2013 · 11 comments
Open

Setup fails if default encoding != utf8 #127

jajadinimueter opened this issue Sep 16, 2013 · 11 comments

Comments

@jajadinimueter
Copy link

This is due to non-ascii characters in docs/HISTORY.txt.

The problem is, that even when we specify the encoding in setup.py the setup still fails because distutils does not care about encodings when writing package meta info. So I really don't know how to fix this.

@fschulze
Copy link
Owner

From http://stackoverflow.com/a/11742928:

The only supported default encodings in Python are:

Python 2.x: ASCII
Python 3.x: UTF-8

If you change these, you are on your own and strange things will
start to happen.

@jajadinimueter
Copy link
Author

My proposal is not to change the default encoding in python, but maybe change the HISTORY.TXT file so it does not contain non-ascii characters to make the setup independent of the operating systems default encoding.

@fschulze
Copy link
Owner

The problem is, that the default encoding is changed. Look at the output of this on the machine you have problems on:

import sys
print sys.getdefaultencoding()

@fschulze
Copy link
Owner

We live in 2013, unicode characters should work and people have a right to have their name written correctly.

@witsch
Copy link
Collaborator

witsch commented Sep 16, 2013

+1!

@fschulze
Copy link
Owner

Oh and just to be clear. I want to fix this, but not by using ascii only. So any help to let me reproduce this issue is highly appreciated. So far I couldn't find a way to break this on the machines I have access to.

@jajadinimueter
Copy link
Author

Yeah, I wouldn't be too happy with the "remove utf-8 characters from history.txt"...

Anyhow, I created a test script for you at https://github.com/jajadinimueter/mr.developer-encoding-error.git

I'm using ubuntu linux. This will create default freebsd locale settings and the install process will fail.

@joka
Copy link

joka commented Sep 17, 2013

This also happens with Debian systems.
You only have to use a minmal image without locale package or set your locale setting to none:

export LANG= 

For those systems we could just catch the error:

diff --git a/setup.py b/setup.py
index 1ff0239..ac1f5ec 100644
--- a/setup.py
+++ b/setup.py
@@ -29,12 +29,19 @@ extra = {}
 if sys.version_info >= (3,):
     extra['use_2to3'] = True

+long_description = ""
+try:
+    long_description = open("README.rst").read()\
+                       + "\n\n"\
+                       + open(os.path.join("docs", "HELP.txt")).read()\
+                       + open(os.path.join("docs", "HISTORY.txt")).read()
+except UnicodeDecodeError:
+    pass
+
 setup(name='mr.developer',
       version=version,
       description="A zc.buildout extension to ease the development of large projects with lots of packages.",
-      long_description=open("README.rst").read() + "\n\n" +
-                       open(os.path.join("docs", "HELP.txt")).read() +
-                       open(os.path.join("docs", "HISTORY.txt")).read(),
+      long_description=long_description,
       # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
       classifiers=[
         "Programming Language :: Python",

fschulze added a commit that referenced this issue Sep 17, 2013
@fschulze
Copy link
Owner

This should now be fixed on master. Thanks for script jajadinimueter!

@jajadinimueter
Copy link
Author

Works for me! Even though my script did some things wrong it works never the less. Thank you very much!

@fschulze
Copy link
Owner

I fixed the script locally :) It was very helpful though, especially that it was easy to switch the python version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants