-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
create virtualenv failed via eclipse pydev debug while succeeded via run #1423
Comments
Fixed code as follows: script = textwrap.dedent(
"""
import sys
import pkgutil
import tempfile
import os
defined_cert = {defined_cert}
try:
from pip._internal import main as _main
cert_data = pkgutil.get_data("pip._vendor.certifi", "cacert.pem")
except ImportError:
from pip import main as _main
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
except IOError:
cert_data = None
if not defined_cert and cert_data is not None:
cert_file = tempfile.NamedTemporaryFile(delete=False)
cert_file.write(cert_data)
cert_file.close()
else:
cert_file = None
try:
args = ["install"] + [{extra_args}]
if cert_file is not None:
args += ["--cert", cert_file.name]
args += sys.argv[-3:]
sys.exit(_main(args))
finally:
if cert_file is not None:
os.remove(cert_file.name)
""".format(
defined_cert=defined_cert, extra_args=", ".join(repr(i) for i in extra_args)
)
).encode("utf8") |
I've seen the same issue on Pycharm and it's supposed to be on vscode either. |
@guyingzhao technically this is a pydev BUG, as it does not correctly handles rewrites when the input script is feed via the stdin (which is a perfectly valid use case). Will not manifest with the next generation virtualenv (WIP) inside #1366 #1377. Will be automatically solved by that by side-stepping. |
@gaborbernat ok, I will temporarily resolve this by myself and wait for official update. |
Reproducible script:
I've add some print info to clearly address the issue.
If you execute above script using eclipse pydev debug, you will get:
And if you execute above script using eclipse pydev run, no error would be raised, and you will get:
pip list
outputmacos
Reason:
pydev debugger will rewrite command line and virtualenv cannot recognize the corresponding modification, it simply cascade the sys.argv[1:] to pre-defined args.
Fix:
using sys.argv[-3:] instead of sys.argv[1:]
The text was updated successfully, but these errors were encountered: