-
Notifications
You must be signed in to change notification settings - Fork 947
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
Fix #463 by using io.open #562
Conversation
@@ -2,6 +2,7 @@ | |||
import re | |||
from setuptools import find_packages | |||
from setuptools import setup | |||
from io import open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer import io
and using io.open
below, otherwise it looks like you're using the builtin open
.
Follow up to previous note, it looks like |
version = re.search('__version__ = "(.*)"', init_py).groups()[0] | ||
with io.open(os.path.join(here, 'lasagne', '__init__.py'), 'r') as f: | ||
init_py = f.read() | ||
version = re.search('__version__ = "(.*)"', init_py).groups()[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the nitpick, but the last line should be left unindented as before. It's not part of the file operation. Thanks!
Thanks for checking! I'd still prefer Could you fix my last comment and then squash everything into a single commit? (Let me know if you don't know how.) Thanks! |
1a4ace7
to
fda7237
Compare
Everything should be nice and tidy now (I definitely did not make a mess of things trying to squash those commits) I think it makes more sense to have the operations that are dependent on the file to be inside the with statement, but I think that comes down to personal preference. |
Hey, I could be wrong, but AFAIK there is no way to use non-ascii text as setup.py metadata in a reliable way across different Python interpreters (see e.g. pypa/pip#761). At least I gave up doing this :) I don't recall all the details, but the data type is different in Python 2 and Python 3, and different setup.py commands (e.g. setup.py sdist or setup.py register or setup.py install) may require different data types (bytes or unicode) in Python 2. For Python3-only solution unicode is the way to go, but AFAIK to support all Python 2 users there must be no non-ascii text in long_description. Maybe things changed, but last time I checked it was a can of worms with lots of edge cases and various pip and distutils bugs. |
From your pr here, it looks like only 2.5 failed, and 2.5 isn't supported here any way. I think the fix here should be sufficient for the needs here (?) Alternatively, unicode in README and CHANGES could be replaced with ascii. |
@dankolbman I don't know, maybe you're right, it was a long time ago and I haven't checked it since then. But other packages seems to follow 'don't use non-ascii text in setup.py' rule in 2015 - e.g. requests did it here: https://github.com/kennethreitz/requests/pull/2420. |
@kmike: Thanks for looking into this! I was always weary of unconditionally changing the description to be My other fear was that we might not want to set the version string to Thanks for scrutinizing this issue so thoroughly! |
I'm tempted to just roll it back and only catch the Tell me if you agree with this and I'll get the appropriate changes in place. On a side note, I found there was a problem in my environment when a bunch of other packages failed from pip. Something was keeping me in the ascii locale which prevented a quick workaround and led me to think this was more a fault of the package than of my own. Anyone with a properly configured environment should have no problem doing a quick |
It's not very obvious that this is the solution, though, and I think it's a fault of the package to assume that the user will always have a UTF8 locale. The package knows that the files it's going to read are encoded in UTF8, so it should act accordingly.
How can we ensure that, though? I think this is a little risky. Maybe it's a bad idea to catch
And the other reading operation could be prepended with:
Could you live with that? Just catching I'm still glad we discussed this in detail and not just applied the first fix we could think of! I would have been afraid of breaking something else then. |
3e45b6f
to
38840d8
Compare
No, certainly not, but if it had worked for me the first time, I sure wouldn't have opened this can of worms ;) Alrighty, I agree catching the Ideally, I think this should all be taken care of from pip's side, though sadly it seems to have been on their radar for a while now and no progress has been made. |
If that happens,
Yes... but let's leave it at that now. The can of worms was big enough already :) Finally merging, thanks a lot for all your patience!
They can't. It's our fault not to specify an encoding when reading the file and relying on the user's system to have an UTF8 default encoding. |
Thanks to all of you for looking into this :) |
👍
Ahh yes of course. I don't know what I was thinking there. |
No description provided.