diff --git a/install-poetry.py b/install-poetry.py index 76ddfc51060..d17fab4f8f3 100644 --- a/install-poetry.py +++ b/install-poetry.py @@ -19,7 +19,6 @@ import re import shutil import site -import stat import subprocess import sys import tempfile @@ -548,62 +547,19 @@ def make_bin(self, site_packages: Path, version: str) -> None: f.write( BAT.format( python_executable=python_executable, - poetry_bin=self._bin_dir.joinpath("poetry"), + poetry_bin=str( + self._data_dir.joinpath("venv/Scripts/poetry.exe") + ), ) ) - # Versions of Poetry prior to 1.2.0 did not have the main() - # function at the poetry.console.application level but et he poetry.console one. - main_module = "poetry.console.application" - version_content = site_packages.joinpath("poetry/__version__.py").read_text( - encoding="utf-8" - ) - - current_version_re = re.match('(?ms).*__version__ = "(.+)".*', version_content) - if not current_version_re: - self._write( - colorize( - "warning", - "Unable to get the current Poetry version. Assuming None", - ) - ) - if is_decorated(): - self._write("") - - current_version = "1.2.0" - else: - current_version = current_version_re.group(1) + return - m = self.VERSION_REGEX.match(current_version) - if tuple(int(p) for p in m.groups()[:2]) < (1, 2): - main_module = "poetry.console" + self._data_dir.joinpath("venv/bin/poetry").unlink(missing_ok=True) - with self._bin_dir.joinpath("poetry").open("w", encoding="utf-8") as f: - f.write("#!/usr/bin/env {}\n".format(python_executable)) - - if WINDOWS: - f.write( - BIN.format( - site_packages=str(site_packages.resolve()).replace( - "\\", "\\\\" - ), - main_module=main_module, - ) - ) - else: - f.write( - BIN.format( - site_packages=str(site_packages.resolve()), - main_module=main_module, - ) - ) - - if not WINDOWS: - # Making the file executable - st = os.stat(self._bin_dir.joinpath("poetry").as_posix()) - os.chmod( - self._bin_dir.joinpath("poetry").as_posix(), st.st_mode | stat.S_IEXEC - ) + self._data_dir.joinpath("venv/bin/poetry").symlink_to( + self._bin_dir.joinpath("poetry") + ) def install_poetry(self, version: str, env_path: Path) -> None: self._overwrite(