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

Specifying which Python interpreter stubgen should use #965

Closed
JukkaL opened this issue Oct 25, 2015 · 4 comments
Closed

Specifying which Python interpreter stubgen should use #965

JukkaL opened this issue Oct 25, 2015 · 4 comments

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Oct 25, 2015

Add a -p <path-to-python> option to stubgen that will replace the --py2 option. Mypy would use this interpreter for these things:

  • Determining Python version (2 or 3).
  • Determining Python module search path.
  • Runtime introspection (esp. for generating stubs for C modules).

As pointed out by @gnprice, the current behavior of using the current Python interpreter doesn't make sense when using a virtualenv, as the virtualenv would have mypy dependencies instead of the (third party) modules targeted by stubgen. This would also allow using an arbitrary Python 2 virtualenv.

We may also need a way of specifying PYTHONPATH for the target interpreter separately from the PYTHONPATH used to run mypy.

@gnprice
Copy link
Collaborator

gnprice commented Nov 24, 2015

This came to mind again today, in the context not of stubgen but of mypy itself. Someone on IRC had trouble getting mypy to find the code they were type-checking, because they were depending on a virtualenv and so --use-python-path didn't help them. If we had a -p option, they could use that in the same way for mypy as we were discussing for stubgen.

Would it make sense for the same -p option to apply to both? Perhaps we should retitle this bug to include both.

@JukkaL JukkaL changed the title Specifying which Python interpreter stubgen should use Specifying which Python interpreter mypy and stubgen should use Nov 24, 2015
@JukkaL
Copy link
Collaborator Author

JukkaL commented Nov 24, 2015

Good point -- retitled.

@ddfisher ddfisher added this to the Future milestone Mar 2, 2016
@gnprice gnprice removed the priority label Mar 2, 2016
@gvanrossum gvanrossum removed this from the Future milestone Mar 29, 2017
JukkaL pushed a commit that referenced this issue Apr 9, 2018
This makes it possible to use inline types from installed packages
and use installed stubs according to PEP 561.

Adds `--python-executable` and `--no-site-packages` 
command-line options.

PEP 561: https://www.python.org/dev/peps/pep-0561/

Fixes #2625, #1190, #965.
@emmatyping
Copy link
Collaborator

#4693 added this for mypy.

@JukkaL JukkaL changed the title Specifying which Python interpreter mypy and stubgen should use Specifying which Python interpreter stubgen should use May 18, 2018
@hauntsaninja
Copy link
Collaborator

stubgen gained support for this at some point in the last four years

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

7 participants