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.
Add a
-p <path-to-python>option to stubgen that will replace the--py2option. Mypy would use this interpreter for these things: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.