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

Add support for unicode in README.md #9

Merged
merged 2 commits into from
Mar 31, 2018
Merged

Conversation

jonahweissman
Copy link
Contributor

In setup.py, the contents of README.md are read as a string,
but this fails because it contains a unicode character. By using
the codecs library, the unicode character can be included in the
string.

I wasn't sure if I needed to do anything special to import other packages in setup.py.
Let me know if there's something I need to change.

In setup.py, the contents of README.md are read as a string,
but this fails because it contains a unicode character. By using
the codecs library, the unicode character can be included in the
string.
@stared
Copy link
Owner

stared commented Mar 31, 2018

@jonahweissman Which version of Python do you use?

In Python 3.6 on OSX and Ubuntu I don't notice such problem. While I do support Python 2.7 for library usage, I don't plan to add it to library deployment process.

@jonahweissman
Copy link
Contributor Author

I'm running Python 3.6.4 on Ubuntu 14.04. This what I get when I run pip install livelossplot:

Collecting livelossplot
  Using cached livelossplot-0.1.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-mcgni592/livelossplot/setup.py", line 11, in <module>
        long_description=readme(),
      File "/tmp/pip-build-mcgni592/livelossplot/setup.py", line 5, in readme
        return f.read()
      File "/home/jonah/.conda/envs/odc/lib/python3.6/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 318: ordinal not in range(128)
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mcgni592/livelossplot/

@stared
Copy link
Owner

stared commented Mar 31, 2018

Strange (as I run it on Ubuntu as well). I guess some environment setting overrides the unicode default (some LANG flag?).

Does any change not involving loading other libraries work (e.g. setting encoding='utf-8' in built-in read) work?

@jonahweissman
Copy link
Contributor Author

Yes! I just tested it with open('README.md', encoding='utf-8') and it worked perfectly.

@jonahweissman
Copy link
Contributor Author

It's not really important at this point, but according to the Python docs, the default encoding is None.
(https://docs.python.org/3.5/library/functions.html#open)

@stared stared merged commit fd72c53 into stared:master Mar 31, 2018
@stared
Copy link
Owner

stared commented Mar 31, 2018

Merged, thanks @jonahweissman ! 👍

@jonahweissman
Copy link
Contributor Author

Great! I really appreciate this package, @stared, thank you for creating it!

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

Successfully merging this pull request may close these issues.

None yet

2 participants