Closed
Description
Bug Report
https://github.com/python/mypy/blob/master/mypy/pyinfo.py#L22
uses sys.base_prefix
, but this does not exist in Python 2.
The code should check whether base_prefix
exists, and if not return a copy of prefix
instead.
To Reproduce
Use the options --py2
and --python-executable
.
Mypy will try to execute pyinfo.py using the given interpreter, which will fail.
Actual Behavior
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/conda/lib/python3.9/site-packages/mypy/__main__.py", line 34, in <module>
console_entry()
File "/opt/conda/lib/python3.9/site-packages/mypy/__main__.py", line 12, in console_entry
main(None, sys.stdout, sys.stderr)
File "mypy/main.py", line 96, in main
svf.nsvf.init_handler,
File "mypy/main.py", line 173, in run_build
File "mypy/build.py", line 180, in build
File "mypy/build.py", line 212, in _build
File "mypy/modulefinder.py", line 782, in compute_search_paths
File "mypy/modulefinder.py", line 624, in get_prefixes
import getopt
File "/opt/conda/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/opt/conda/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['.../python2', '/opt/conda/lib/python3.9/site-packages/mypy/pyinfo.py', 'getprefixes']' returned non-zero exit status 1.
Running the command manually gives
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/site-packages/mypy/pyinfo.py", line 43, in <module>
print(repr(getprefixes()))
File "/opt/conda/lib/python3.9/site-packages/mypy/pyinfo.py", line 22, in getprefixes
return sys.base_prefix, sys.prefix
AttributeError: 'module' object has no attribute 'base_prefix'
Your Environment
- Mypy version used: 0.931
- Python version used: 2.7.5, 2.7.17