Skip to content

Commit

Permalink
Move version script string to class constant
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Jan 9, 2022
1 parent f1c0d2a commit 4bcdee7
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions src/poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ class EnvManager:
_env = None

ENVS_FILE = "envs.toml"
VERSION_SCRIPT = (
"\"import sys; print('.'.join([str(s) for s in sys.version_info[:3]]))\""
)

def __init__(self, poetry: "Poetry") -> None:
self._poetry = poetry
Expand Down Expand Up @@ -483,14 +486,7 @@ def activate(self, python: str, io: "IO") -> "Env":
try:
python_version = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([python, "-c", self.VERSION_SCRIPT]),
shell=True,
)
)
Expand Down Expand Up @@ -730,14 +726,7 @@ def remove(self, python: str) -> "Env":
try:
python_version = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([python, "-c", self.VERSION_SCRIPT]),
shell=True,
)
)
Expand Down Expand Up @@ -806,14 +795,7 @@ def create_venv(
if executable:
python_patch = decode(
subprocess.check_output(
list_to_shell_command(
[
executable,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([executable, "-c", self.VERSION_SCRIPT]),
shell=True,
).strip()
)
Expand Down Expand Up @@ -861,14 +843,7 @@ def create_venv(
try:
python_patch = decode(
subprocess.check_output(
list_to_shell_command(
[
python,
"-c",
"\"import sys; print('.'.join([str(s) for s in"
' sys.version_info[:3]]))"',
]
),
list_to_shell_command([python, "-c", self.VERSION_SCRIPT]),
stderr=subprocess.STDOUT,
shell=True,
).strip()
Expand Down

0 comments on commit 4bcdee7

Please sign in to comment.