Skip to content

Commit

Permalink
get-poetry: resolve merge error
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Jul 20, 2020
1 parent b626c87 commit 8c610e1
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions get-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,26 @@ def _compare_versions(x, y):

break

current_version = None
if os.path.exists(POETRY_LIB):
with open(
os.path.join(POETRY_LIB, "poetry", "__version__.py"), encoding="utf-8"
) as f:
version_content = f.read()

current_version_re = re.match(
'(?ms).*__version__ = "(.+)".*', version_content
)
if not current_version_re:
print(
colorize(
"warning",
"Unable to get the current Poetry version. Assuming None",
)
)
else:
current_version = current_version_re.group(1)

if current_version == version and not self._force:
print("Latest version already installed.")
return None, current_version
Expand Down Expand Up @@ -637,6 +657,7 @@ def _which_python(self):
if match and tuple(map(int, match.groups())) >= (3, 0):
# favor the first py3 executable we can find.
return executable

if fallback is None:
# keep this one as the fallback; it was the first valid executable we found.
fallback = executable
Expand Down Expand Up @@ -669,8 +690,10 @@ def make_bin(self):
)

with open(os.path.join(POETRY_BIN, "poetry"), "w", encoding="utf-8") as f:
if not WINDOWS:
f.write(u("#!/usr/bin/env {}\n".format(python_executable)))
if WINDOWS:
python_executable = "python"

f.write(u("#!/usr/bin/env {}\n".format(python_executable)))
f.write(u(BIN))

if not WINDOWS:
Expand Down

0 comments on commit 8c610e1

Please sign in to comment.