From 33328c435ab028faae36709cbeb930ee5602d774 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Sun, 15 Jul 2018 17:00:25 -0400 Subject: [PATCH] Fully integrate pythonfinder for system pythons Signed-off-by: Dan Ryan --- pipenv/core.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pipenv/core.py b/pipenv/core.py index b059ddc9..38cb5b7b 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -315,17 +315,24 @@ def ensure_pipfile(validate=True, skip_requirements=False, system=False): def find_a_system_python(python): + from .vendor.pythonfinder import Finder + # system always refers to sys.executable, which could point at a virtualenv + # for global searches we most likely want to turn that off + finder = Finder(system=False, global_search=True) if not python: return None + # when using the python launcher on windows we can find the versions ourselves + if os.name == 'nt' and python.startswith("py -"): + python = python[len("py -"):] if python.startswith("py"): - return system_which(python) + python_entry = finder.which(python) + if python_entry: + return python_entry.path.as_posix() if os.path.isabs(python): return python - from .vendor import pythonfinder - finder = pythonfinder.Finder() python_entry = finder.find_python_version(python) if python_entry: - return str(python_entry.path) + return python_entry.path.as_posix() return None