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

Generated scripts can be written in a bogus encoding #1246

Open
habnabit opened this issue Jan 3, 2018 · 10 comments
Open

Generated scripts can be written in a bogus encoding #1246

habnabit opened this issue Jan 3, 2018 · 10 comments
Labels
bug help wanted Needs Investigation Issues which are likely in scope but need investigation to figure out the cause

Comments

@habnabit
Copy link

habnabit commented Jan 3, 2018

with open(target, "w" + mode) as f:
f.write(contents)

open's encoding argument, when unspecified, uses locale.getpreferredencoding , which is not necessarily UTF-8. However, the generated script doesn't include an encoding cookie and can contain non-ASCII data if, say, the shebang path contains non-ASCII components. Either always open the file with encoding='utf-8' or write out an encoding cookie.

This has resulted in an issue filed on a different project: pypa/pipenv#1265

@jaraco
Copy link
Member

jaraco commented Jan 3, 2018

My intention for issues like this one is to replace Setuptools own script generation with that found in distlib.

Plus, easy_install is generally deprecated.

@habnabit
Copy link
Author

habnabit commented Jan 3, 2018

Sure. Even if easy_install is deprecated, it seems like you'd want to either delete the functionality surrounding this or fix it.

@jaraco
Copy link
Member

jaraco commented Jan 4, 2018

The issue reported upstream implicates a script installed by pip and distlib and not setuptools. The issue should be filed with distlib and will only be addressed by setuptools if setuptools adopts distlib instead of its own executable wrapper implementation.

@jaraco jaraco closed this as completed Jan 4, 2018
@habnabit
Copy link
Author

habnabit commented Jan 4, 2018

Regardless of the upstream issue, do you see how this affects setuptools? I can reproduce this, but not exactly right now, as I don't have a windows box readily available.

@jaraco
Copy link
Member

jaraco commented Jan 20, 2018

I do see how setuptools could be affected, but it's not clear to me that this is a use case we wish to support. I don't fully understand which factors are necessary to bring about these invalid encodings. In fact, if the system's preferred encoding is not UTF-8, perhaps that indicates that the system wishes not to have UTF-8 in the scripts.

I don't feel strongly about it, but I do feel a little uneasy fixing a bug that's never been encountered in a piece of code that's deprecated.

I've gone ahead and pushed a possible change to a branch. Would you review and confirm this is what you had in mind?

@jaraco
Copy link
Member

jaraco commented Jan 20, 2018

Following up in the parent ticket, I see that in fact easy_install is used regularly for installing source distributions, even when pip is doing the builds unless wheel is used. So this issue is very relevant to common workflows.

@jaraco jaraco reopened this Jan 20, 2018
@uranusjr
Copy link
Member

Being curious here, why does pip use setuptools when installing from source? Would it be plausible to also raise this issue in pip?

@jaraco
Copy link
Member

jaraco commented Feb 3, 2018

raise this issue in pip?

Looks like it's already done.

@pganssle pganssle added Needs Triage Issues that need to be evaluated for severity and status. bug help wanted Needs Investigation Issues which are likely in scope but need investigation to figure out the cause and removed Needs Triage Issues that need to be evaluated for severity and status. labels Oct 19, 2018
@pganssle
Copy link
Member

Is this related to #1400?

@habnabit
Copy link
Author

@pganssle AFAICT #1400 is a duplicate of this issue yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted Needs Investigation Issues which are likely in scope but need investigation to figure out the cause
Projects
None yet
Development

No branches or pull requests

4 participants