Skip to content

Commit

Permalink
get_python_version returns string
Browse files Browse the repository at this point in the history
  • Loading branch information
frostming committed Feb 14, 2020
1 parent 01a1361 commit 96374c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pdm/cli/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def do_info(
) -> None:
"""Show project information."""
python_path = project.environment.python_executable
python_version = get_python_version(python_path)
python_version = get_python_version(python_path, True)
if not python and not show_project and not env:
rows = [
(
Expand Down
5 changes: 1 addition & 4 deletions pdm/models/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def __init__(self, python_requires: PySpecSet, config: Config) -> None:
@cached_property
def python_executable(self) -> str:
"""Get the Python interpreter path."""
path = None
if self.config["python"]:
path = self.config["python"]
try:
Expand All @@ -93,16 +92,14 @@ def python_executable(self) -> str:
except Exception:
pass

path = None
version = None
# First try what `python` refers to.
path = shutil.which("python")
if path:
version = get_python_version(path, True)
else:
finder = Finder()
for python in finder.find_all_python_versions():
version = ".".join(map(str, get_python_version(python.path.as_posix())))
version = get_python_version(python.path.as_posix(), True)
if self.python_requires.contains(version):
path = python.path.as_posix()
break
Expand Down

0 comments on commit 96374c5

Please sign in to comment.