Skip to content

Ways to install the codec. #877

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

Closed
o11c opened this issue Sep 20, 2015 · 3 comments
Closed

Ways to install the codec. #877

o11c opened this issue Sep 20, 2015 · 3 comments

Comments

@o11c
Copy link
Contributor

o11c commented Sep 20, 2015

I just realized adding a .pth file to site-packages allows execution of arbitrary code (as long as the line starts with import). That could be used to hook up the encoding without requiring the user to do it explicitly (this is impossible with the main file anyway).

Unfortunately this does not work for the current directory, only the system and user site-packages directories.

Instead of directly registering the codec (from the .pth file), it might be possible to set a custom __path__ element in encodings, that should enable autodiscovery.

@o11c
Copy link
Contributor Author

o11c commented Sep 20, 2015

Note, I also looked at sitecustomize.py and usercustomize.py, but those only works if you export PYTHONPATH=., i.e. not in the implicit path from the script which is apparently only set later.

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 1, 2015

Having the encoding available implicitly would be handy, though only if it doesn't significantly slow down the start up of programs that don't use the encoding (i.e., I'd like to import the implementation of the encoding lazily).

I wonder what the best practice for doing this would be? At least we can document how to do this manually. Or maybe we could have a separate package for the codec that would do this automatically.

@o11c
Copy link
Contributor Author

o11c commented Oct 1, 2015

Yeah, obviously the python2-only bits need to be installable separately from the python3 mypy proper.

I put some thoughts in #724

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

No branches or pull requests

3 participants