Add base vars and sudo check
This commit is contained in:
parent
c151fd6910
commit
054f5ad80c
8733 changed files with 137813 additions and 15 deletions
1
venv/lib/python3.8/site-packages/poetry/console/__init__.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/__init__.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/b7/0d/8f/08df39bd37124d2bfb7fb960465cbae8dc1ba4b60f35c780b4a340289a
|
Binary file not shown.
Binary file not shown.
1
venv/lib/python3.8/site-packages/poetry/console/application.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/application.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/93/54/43/34a1f5a86fad4d32557fdcb57bf825be226d5946bc79c619e42a3370b9
|
1
venv/lib/python3.8/site-packages/poetry/console/args/__init__.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/args/__init__.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/23/9f/ac/b3e93052f1b90483e9cd1db93a097ac8328f98110a6bba1acf1f21e8d6
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/9d/08/7c/18a7a498302ec6661ccc84ece5e906563ec815e3dfb3aad28a64457d9f
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/95/85/30/7ad2c59cddcb12b6a22c7357bcf7384c633aa034fac7eb4f1a9740597e
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/add.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/add.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/1c/7d/9e/c86030c499e2e107e117a32efd0e0dff7bc978f0dc20d2551de64624c7
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/07/6b/75/de609cafa3eb7e6d313a4c77a7b41f6e0aa2403539e1b5620e79523b61
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__init__.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__init__.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/cache.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/cache.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/clear.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/clear.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/list.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/cache/__pycache__/list.cpython-38.pyc
vendored
Normal file
Binary file not shown.
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/cache.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/cache.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/4e/b3/35/7cbd7e7e15fb7d65b2d4718be80ff132979c7911869d9a73c529cb36d9
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/clear.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/clear.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/ea/ed/43/91e0c3c817da7d0207f20f79336e6a9b27cab13e1d6a3706b029b48e6a
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/list.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/cache/list.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/b4/81/3a/1c283bb17d91ad2ea6016b9590030f514026690d7755b11b75b651fc06
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/52/34/42/f7ea358f0cbd8deb3500db15cd1149e8ca7f17cf85831e96ea35bb5e7c
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/56/84/72/17e2777b4dde572c90f35acc44886554c20a643ee1fa9fd8f6eed92f51
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e0/3c/d7/56913e00137a9bdab4e9cb1d3d22b887617c9d3eea1861f0c7cf25618b
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/d6/c7/dd/6f5d353082452c657750c77ff7fefe6d948a16ed25c28e5ee2daade499
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/61/e5/8a/58fe498f62a4f685eff7bd7dd3341ab3eb4b95174afca13824bc4b29d2
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/0f/fd/f3/4bef30bd1bd7a144739cac56e6c5b4d272cd6752168d971bbf37ec956c
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/__init__.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/__init__.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/__init__.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/env.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/env.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/info.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/info.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/list.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/list.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/remove.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/remove.cpython-38.pyc
vendored
Normal file
Binary file not shown.
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/use.cpython-38.pyc
vendored
Normal file
BIN
venv/lib/python3.8/site-packages/poetry/console/commands/env/__pycache__/use.cpython-38.pyc
vendored
Normal file
Binary file not shown.
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/env.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/env.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/80/4c/3b/8f4091c562fdf46b1bf67e271ca89f9f1afd717358edb31564b0fd36e5
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/info.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/info.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/08/80/e1/f088ce7587eac445c1e84a6b942175d0ee8925fffbeaae5946b76c08d4
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/list.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/list.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/54/be/e6/c90be5a9509939704073dab02025be7f436744820dcb74d9cb0a208d52
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/remove.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/remove.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/54/10/11/1f3ccc887810e21c2d1ef9a7066e207e08448f16097bdcfd3a38e5f6d6
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/use.py
vendored
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/env/use.py
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/25/a1/9f/70ee6cfdde3c30eff065df37aef29f108be5735ab6bb87de91303cc443
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/39/91/cc/ae9428839923699ea5f83a6e6d3f8cc8f9f4f611c012503cb403288a81
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/d1/97/58/7c34b2bacb8425319e75d3608a88c6f204aa5f3c5afaec0d4a17d62e46
|
546
venv/lib/python3.8/site-packages/poetry/console/commands/init.py
Normal file
546
venv/lib/python3.8/site-packages/poetry/console/commands/init.py
Normal file
|
@ -0,0 +1,546 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
from cleo import option
|
||||
from tomlkit import inline_table
|
||||
|
||||
from poetry.core.pyproject import PyProjectException
|
||||
from poetry.core.pyproject.toml import PyProjectTOML
|
||||
from poetry.utils._compat import OrderedDict
|
||||
from poetry.utils._compat import Path
|
||||
from poetry.utils._compat import urlparse
|
||||
|
||||
from .command import Command
|
||||
from .env_command import EnvCommand
|
||||
|
||||
|
||||
class InitCommand(Command):
|
||||
name = "init"
|
||||
description = (
|
||||
"Creates a basic <comment>pyproject.toml</> file in the current directory."
|
||||
)
|
||||
|
||||
options = [
|
||||
option("name", None, "Name of the package.", flag=False),
|
||||
option("description", None, "Description of the package.", flag=False),
|
||||
option("author", None, "Author name of the package.", flag=False),
|
||||
option("python", None, "Compatible Python versions.", flag=False),
|
||||
option(
|
||||
"dependency",
|
||||
None,
|
||||
"Package to require, with an optional version constraint, "
|
||||
"e.g. requests:^2.10.0 or requests=2.11.1.",
|
||||
flag=False,
|
||||
multiple=True,
|
||||
),
|
||||
option(
|
||||
"dev-dependency",
|
||||
None,
|
||||
"Package to require for development, with an optional version constraint, "
|
||||
"e.g. requests:^2.10.0 or requests=2.11.1.",
|
||||
flag=False,
|
||||
multiple=True,
|
||||
),
|
||||
option("license", "l", "License of the package.", flag=False),
|
||||
]
|
||||
|
||||
help = """\
|
||||
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the current directory.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(InitCommand, self).__init__()
|
||||
|
||||
self._pool = None
|
||||
|
||||
def handle(self):
|
||||
from poetry.core.vcs.git import GitConfig
|
||||
from poetry.layouts import layout
|
||||
from poetry.utils._compat import Path
|
||||
from poetry.utils.env import SystemEnv
|
||||
|
||||
pyproject = PyProjectTOML(Path.cwd() / "pyproject.toml")
|
||||
|
||||
if pyproject.file.exists():
|
||||
if pyproject.is_poetry_project():
|
||||
self.line(
|
||||
"<error>A pyproject.toml file with a poetry section already exists.</error>"
|
||||
)
|
||||
return 1
|
||||
|
||||
if pyproject.data.get("build-system"):
|
||||
self.line(
|
||||
"<error>A pyproject.toml file with a defined build-system already exists.</error>"
|
||||
)
|
||||
return 1
|
||||
|
||||
vcs_config = GitConfig()
|
||||
|
||||
self.line("")
|
||||
self.line(
|
||||
"This command will guide you through creating your <info>pyproject.toml</> config."
|
||||
)
|
||||
self.line("")
|
||||
|
||||
name = self.option("name")
|
||||
if not name:
|
||||
name = Path.cwd().name.lower()
|
||||
|
||||
question = self.create_question(
|
||||
"Package name [<comment>{}</comment>]: ".format(name), default=name
|
||||
)
|
||||
name = self.ask(question)
|
||||
|
||||
version = "0.1.0"
|
||||
question = self.create_question(
|
||||
"Version [<comment>{}</comment>]: ".format(version), default=version
|
||||
)
|
||||
version = self.ask(question)
|
||||
|
||||
description = self.option("description") or ""
|
||||
question = self.create_question(
|
||||
"Description [<comment>{}</comment>]: ".format(description),
|
||||
default=description,
|
||||
)
|
||||
description = self.ask(question)
|
||||
|
||||
author = self.option("author")
|
||||
if not author and vcs_config and vcs_config.get("user.name"):
|
||||
author = vcs_config["user.name"]
|
||||
author_email = vcs_config.get("user.email")
|
||||
if author_email:
|
||||
author += " <{}>".format(author_email)
|
||||
|
||||
question = self.create_question(
|
||||
"Author [<comment>{}</comment>, n to skip]: ".format(author), default=author
|
||||
)
|
||||
question.set_validator(lambda v: self._validate_author(v, author))
|
||||
author = self.ask(question)
|
||||
|
||||
if not author:
|
||||
authors = []
|
||||
else:
|
||||
authors = [author]
|
||||
|
||||
license = self.option("license") or ""
|
||||
|
||||
question = self.create_question(
|
||||
"License [<comment>{}</comment>]: ".format(license), default=license
|
||||
)
|
||||
question.set_validator(self._validate_license)
|
||||
license = self.ask(question)
|
||||
|
||||
python = self.option("python")
|
||||
if not python:
|
||||
current_env = SystemEnv(Path(sys.executable))
|
||||
default_python = "^{}".format(
|
||||
".".join(str(v) for v in current_env.version_info[:2])
|
||||
)
|
||||
question = self.create_question(
|
||||
"Compatible Python versions [<comment>{}</comment>]: ".format(
|
||||
default_python
|
||||
),
|
||||
default=default_python,
|
||||
)
|
||||
python = self.ask(question)
|
||||
|
||||
self.line("")
|
||||
|
||||
requirements = {}
|
||||
if self.option("dependency"):
|
||||
requirements = self._format_requirements(
|
||||
self._determine_requirements(self.option("dependency"))
|
||||
)
|
||||
|
||||
question = "Would you like to define your main dependencies interactively?"
|
||||
help_message = (
|
||||
"You can specify a package in the following forms:\n"
|
||||
" - A single name (<b>requests</b>)\n"
|
||||
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
|
||||
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
|
||||
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
|
||||
" - A file path (<b>../my-package/my-package.whl</b>)\n"
|
||||
" - A directory (<b>../my-package/</b>)\n"
|
||||
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
|
||||
)
|
||||
help_displayed = False
|
||||
if self.confirm(question, True):
|
||||
self.line(help_message)
|
||||
help_displayed = True
|
||||
requirements.update(
|
||||
self._format_requirements(self._determine_requirements([]))
|
||||
)
|
||||
self.line("")
|
||||
|
||||
dev_requirements = {}
|
||||
if self.option("dev-dependency"):
|
||||
dev_requirements = self._format_requirements(
|
||||
self._determine_requirements(self.option("dev-dependency"))
|
||||
)
|
||||
|
||||
question = (
|
||||
"Would you like to define your development dependencies interactively?"
|
||||
)
|
||||
if self.confirm(question, True):
|
||||
if not help_displayed:
|
||||
self.line(help_message)
|
||||
|
||||
dev_requirements.update(
|
||||
self._format_requirements(self._determine_requirements([]))
|
||||
)
|
||||
self.line("")
|
||||
|
||||
layout_ = layout("standard")(
|
||||
name,
|
||||
version,
|
||||
description=description,
|
||||
author=authors[0] if authors else None,
|
||||
license=license,
|
||||
python=python,
|
||||
dependencies=requirements,
|
||||
dev_dependencies=dev_requirements,
|
||||
)
|
||||
|
||||
content = layout_.generate_poetry_content(original=pyproject)
|
||||
if self.io.is_interactive():
|
||||
self.line("<info>Generated file</info>")
|
||||
self.line("")
|
||||
self.line(content)
|
||||
self.line("")
|
||||
|
||||
if not self.confirm("Do you confirm generation?", True):
|
||||
self.line("<error>Command aborted</error>")
|
||||
|
||||
return 1
|
||||
|
||||
with (Path.cwd() / "pyproject.toml").open("w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
def _determine_requirements(
|
||||
self, requires, allow_prereleases=False, source=None
|
||||
): # type: (List[str], bool) -> List[Dict[str, str]]
|
||||
if not requires:
|
||||
requires = []
|
||||
|
||||
package = self.ask(
|
||||
"Search for package to add (or leave blank to continue):"
|
||||
)
|
||||
while package is not None:
|
||||
constraint = self._parse_requirements([package])[0]
|
||||
if (
|
||||
"git" in constraint
|
||||
or "url" in constraint
|
||||
or "path" in constraint
|
||||
or "version" in constraint
|
||||
):
|
||||
self.line("Adding <info>{}</info>".format(package))
|
||||
requires.append(constraint)
|
||||
package = self.ask("\nAdd a package:")
|
||||
continue
|
||||
|
||||
matches = self._get_pool().search(constraint["name"])
|
||||
|
||||
if not matches:
|
||||
self.line("<error>Unable to find package</error>")
|
||||
package = False
|
||||
else:
|
||||
choices = []
|
||||
matches_names = [p.name for p in matches]
|
||||
exact_match = constraint["name"] in matches_names
|
||||
if exact_match:
|
||||
choices.append(
|
||||
matches[matches_names.index(constraint["name"])].pretty_name
|
||||
)
|
||||
|
||||
for found_package in matches:
|
||||
if len(choices) >= 10:
|
||||
break
|
||||
|
||||
if found_package.name.lower() == constraint["name"].lower():
|
||||
continue
|
||||
|
||||
choices.append(found_package.pretty_name)
|
||||
|
||||
self.line(
|
||||
"Found <info>{}</info> packages matching <c1>{}</c1>".format(
|
||||
len(matches), package
|
||||
)
|
||||
)
|
||||
|
||||
package = self.choice(
|
||||
"\nEnter package # to add, or the complete package name if it is not listed",
|
||||
choices,
|
||||
attempts=3,
|
||||
)
|
||||
|
||||
# package selected by user, set constraint name to package name
|
||||
if package is not False:
|
||||
constraint["name"] = package
|
||||
|
||||
# no constraint yet, determine the best version automatically
|
||||
if package is not False and "version" not in constraint:
|
||||
question = self.create_question(
|
||||
"Enter the version constraint to require "
|
||||
"(or leave blank to use the latest version):"
|
||||
)
|
||||
question.attempts = 3
|
||||
question.validator = lambda x: (x or "").strip() or False
|
||||
|
||||
package_constraint = self.ask(question)
|
||||
|
||||
if package_constraint is None:
|
||||
_, package_constraint = self._find_best_version_for_package(
|
||||
package
|
||||
)
|
||||
|
||||
self.line(
|
||||
"Using version <b>{}</b> for <c1>{}</c1>".format(
|
||||
package_constraint, package
|
||||
)
|
||||
)
|
||||
|
||||
constraint["version"] = package_constraint
|
||||
|
||||
if package is not False:
|
||||
requires.append(constraint)
|
||||
|
||||
package = self.ask("\nAdd a package:")
|
||||
|
||||
return requires
|
||||
|
||||
requires = self._parse_requirements(requires)
|
||||
result = []
|
||||
for requirement in requires:
|
||||
if "git" in requirement or "url" in requirement or "path" in requirement:
|
||||
result.append(requirement)
|
||||
continue
|
||||
elif "version" not in requirement:
|
||||
# determine the best version automatically
|
||||
name, version = self._find_best_version_for_package(
|
||||
requirement["name"],
|
||||
allow_prereleases=allow_prereleases,
|
||||
source=source,
|
||||
)
|
||||
requirement["version"] = version
|
||||
requirement["name"] = name
|
||||
|
||||
self.line(
|
||||
"Using version <b>{}</b> for <c1>{}</c1>".format(version, name)
|
||||
)
|
||||
else:
|
||||
# check that the specified version/constraint exists
|
||||
# before we proceed
|
||||
name, _ = self._find_best_version_for_package(
|
||||
requirement["name"],
|
||||
requirement["version"],
|
||||
allow_prereleases=allow_prereleases,
|
||||
source=source,
|
||||
)
|
||||
|
||||
requirement["name"] = name
|
||||
|
||||
result.append(requirement)
|
||||
|
||||
return result
|
||||
|
||||
def _find_best_version_for_package(
|
||||
self, name, required_version=None, allow_prereleases=False, source=None
|
||||
): # type: (...) -> Tuple[str, str]
|
||||
from poetry.version.version_selector import VersionSelector
|
||||
|
||||
selector = VersionSelector(self._get_pool())
|
||||
package = selector.find_best_candidate(
|
||||
name, required_version, allow_prereleases=allow_prereleases, source=source
|
||||
)
|
||||
|
||||
if not package:
|
||||
# TODO: find similar
|
||||
raise ValueError(
|
||||
"Could not find a matching version of package {}".format(name)
|
||||
)
|
||||
|
||||
return package.pretty_name, selector.find_recommended_require_version(package)
|
||||
|
||||
def _parse_requirements(
|
||||
self, requirements
|
||||
): # type: (List[str]) -> List[Dict[str, str]]
|
||||
from poetry.puzzle.provider import Provider
|
||||
|
||||
result = []
|
||||
|
||||
try:
|
||||
cwd = self.poetry.file.parent
|
||||
except (PyProjectException, RuntimeError):
|
||||
cwd = Path.cwd()
|
||||
|
||||
for requirement in requirements:
|
||||
requirement = requirement.strip()
|
||||
extras = []
|
||||
extras_m = re.search(r"\[([\w\d,-_ ]+)\]$", requirement)
|
||||
if extras_m:
|
||||
extras = [e.strip() for e in extras_m.group(1).split(",")]
|
||||
requirement, _ = requirement.split("[")
|
||||
|
||||
url_parsed = urlparse.urlparse(requirement)
|
||||
if url_parsed.scheme and url_parsed.netloc:
|
||||
# Url
|
||||
if url_parsed.scheme in ["git+https", "git+ssh"]:
|
||||
from poetry.core.vcs.git import Git
|
||||
from poetry.core.vcs.git import ParsedUrl
|
||||
|
||||
parsed = ParsedUrl.parse(requirement)
|
||||
url = Git.normalize_url(requirement)
|
||||
|
||||
pair = OrderedDict([("name", parsed.name), ("git", url.url)])
|
||||
if parsed.rev:
|
||||
pair["rev"] = url.revision
|
||||
|
||||
if extras:
|
||||
pair["extras"] = extras
|
||||
|
||||
package = Provider.get_package_from_vcs(
|
||||
"git", url.url, rev=pair.get("rev")
|
||||
)
|
||||
pair["name"] = package.name
|
||||
result.append(pair)
|
||||
|
||||
continue
|
||||
elif url_parsed.scheme in ["http", "https"]:
|
||||
package = Provider.get_package_from_url(requirement)
|
||||
|
||||
pair = OrderedDict(
|
||||
[("name", package.name), ("url", package.source_url)]
|
||||
)
|
||||
if extras:
|
||||
pair["extras"] = extras
|
||||
|
||||
result.append(pair)
|
||||
continue
|
||||
elif (os.path.sep in requirement or "/" in requirement) and cwd.joinpath(
|
||||
requirement
|
||||
).exists():
|
||||
path = cwd.joinpath(requirement)
|
||||
if path.is_file():
|
||||
package = Provider.get_package_from_file(path.resolve())
|
||||
else:
|
||||
package = Provider.get_package_from_directory(path)
|
||||
|
||||
result.append(
|
||||
OrderedDict(
|
||||
[
|
||||
("name", package.name),
|
||||
("path", path.relative_to(cwd).as_posix()),
|
||||
]
|
||||
+ ([("extras", extras)] if extras else [])
|
||||
)
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
pair = re.sub(
|
||||
"^([^@=: ]+)(?:@|==|(?<![<>~!])=|:| )(.*)$", "\\1 \\2", requirement
|
||||
)
|
||||
pair = pair.strip()
|
||||
|
||||
require = OrderedDict()
|
||||
if " " in pair:
|
||||
name, version = pair.split(" ", 2)
|
||||
extras_m = re.search(r"\[([\w\d,-_]+)\]$", name)
|
||||
if extras_m:
|
||||
extras = [e.strip() for e in extras_m.group(1).split(",")]
|
||||
name, _ = name.split("[")
|
||||
|
||||
require["name"] = name
|
||||
if version != "latest":
|
||||
require["version"] = version
|
||||
else:
|
||||
m = re.match(
|
||||
r"^([^><=!: ]+)((?:>=|<=|>|<|!=|~=|~|\^).*)$", requirement.strip()
|
||||
)
|
||||
if m:
|
||||
name, constraint = m.group(1), m.group(2)
|
||||
extras_m = re.search(r"\[([\w\d,-_]+)\]$", name)
|
||||
if extras_m:
|
||||
extras = [e.strip() for e in extras_m.group(1).split(",")]
|
||||
name, _ = name.split("[")
|
||||
|
||||
require["name"] = name
|
||||
require["version"] = constraint
|
||||
else:
|
||||
extras_m = re.search(r"\[([\w\d,-_]+)\]$", pair)
|
||||
if extras_m:
|
||||
extras = [e.strip() for e in extras_m.group(1).split(",")]
|
||||
pair, _ = pair.split("[")
|
||||
|
||||
require["name"] = pair
|
||||
|
||||
if extras:
|
||||
require["extras"] = extras
|
||||
|
||||
result.append(require)
|
||||
|
||||
return result
|
||||
|
||||
def _format_requirements(
|
||||
self, requirements
|
||||
): # type: (List[Dict[str, str]]) -> Dict[str, Union[str, Dict[str, str]]]
|
||||
requires = {}
|
||||
for requirement in requirements:
|
||||
name = requirement.pop("name")
|
||||
if "version" in requirement and len(requirement) == 1:
|
||||
constraint = requirement["version"]
|
||||
else:
|
||||
constraint = inline_table()
|
||||
constraint.trivia.trail = "\n"
|
||||
constraint.update(requirement)
|
||||
|
||||
requires[name] = constraint
|
||||
|
||||
return requires
|
||||
|
||||
def _validate_author(self, author, default):
|
||||
from poetry.core.packages.package import AUTHOR_REGEX
|
||||
|
||||
author = author or default
|
||||
|
||||
if author in ["n", "no"]:
|
||||
return
|
||||
|
||||
m = AUTHOR_REGEX.match(author)
|
||||
if not m:
|
||||
raise ValueError(
|
||||
"Invalid author string. Must be in the format: "
|
||||
"John Smith <john@example.com>"
|
||||
)
|
||||
|
||||
return author
|
||||
|
||||
def _validate_license(self, license):
|
||||
from poetry.core.spdx import license_by_id
|
||||
|
||||
if license:
|
||||
license_by_id(license)
|
||||
|
||||
return license
|
||||
|
||||
def _get_pool(self):
|
||||
from poetry.repositories import Pool
|
||||
from poetry.repositories.pypi_repository import PyPiRepository
|
||||
|
||||
if isinstance(self, EnvCommand):
|
||||
return self.poetry.pool
|
||||
|
||||
if self._pool is None:
|
||||
self._pool = Pool()
|
||||
self._pool.add_repository(PyPiRepository(config=self.poetry.config))
|
||||
|
||||
return self._pool
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/b6/6d/45/d34a589a1baa1fb70fc7f147d01c0adc22eada0053ec13ef58911cfeea
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/00/05/2c/9064ade063309465b9c038c57ac643e1df3abd1f6ac69eb43b60c854aa
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/lock.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/lock.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/40/4e/54/4dc30f225358504ac2a93685d7323e0851fea2c2a9937f25f1d53d20f9
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/new.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/new.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/7b/09/e4/e0da6343171e3f2885b321628ba20bdc5c731205d283e7c05801bd130a
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/d4/84/89/d5c0f2169d8df085726fcfd76a861826ccb1c4e61e28e5800365c1b5f6
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/de/5e/15/d13e5b2473899a2d7a320b2bab612ab547275cb8eace19d794418977de
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/run.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/run.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/3b/8b/f7/fd3e3e3688b2c321189a73d6fe5e8fa411f42359f7af951e498fae6627
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/1e/77/ef/7af91aa5e612837c51cd66f1bc17e44c155c36c9b1ea80f8b39836c760
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/49/7f/25/1bf09512d6075ebaac8cfbd7a1476311aaa51d4e25c6e82b8887527c29
|
|
@ -0,0 +1,472 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import site
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
from functools import cmp_to_key
|
||||
from gzip import GzipFile
|
||||
|
||||
from cleo import argument
|
||||
from cleo import option
|
||||
|
||||
from poetry.core.packages import Dependency
|
||||
from poetry.utils._compat import PY2
|
||||
from poetry.utils._compat import Path
|
||||
|
||||
from ..command import Command
|
||||
|
||||
|
||||
try:
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
from urllib2 import HTTPError
|
||||
from urllib2 import urlopen
|
||||
|
||||
|
||||
BIN = """# -*- coding: utf-8 -*-
|
||||
import glob
|
||||
import sys
|
||||
import os
|
||||
|
||||
lib = os.path.normpath(os.path.join(os.path.realpath(__file__), "../..", "lib"))
|
||||
vendors = os.path.join(lib, "poetry", "_vendor")
|
||||
current_vendors = os.path.join(
|
||||
vendors, "py{}".format(".".join(str(v) for v in sys.version_info[:2]))
|
||||
)
|
||||
sys.path.insert(0, lib)
|
||||
sys.path.insert(0, current_vendors)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from poetry.console import main
|
||||
main()
|
||||
"""
|
||||
|
||||
BAT = '@echo off\r\n{python_executable} "{poetry_bin}" %*\r\n'
|
||||
|
||||
|
||||
class SelfUpdateCommand(Command):
|
||||
|
||||
name = "update"
|
||||
description = "Updates Poetry to the latest version."
|
||||
|
||||
arguments = [argument("version", "The version to update to.", optional=True)]
|
||||
options = [option("preview", None, "Install prereleases.")]
|
||||
|
||||
REPOSITORY_URL = "https://github.com/python-poetry/poetry"
|
||||
BASE_URL = REPOSITORY_URL + "/releases/download"
|
||||
|
||||
_data_dir = None
|
||||
_bin_dir = None
|
||||
_pool = None
|
||||
|
||||
@property
|
||||
def home(self):
|
||||
from poetry.utils._compat import Path
|
||||
|
||||
return Path(os.environ.get("POETRY_HOME", "~/.poetry")).expanduser()
|
||||
|
||||
@property
|
||||
def bin(self):
|
||||
return self.home / "bin"
|
||||
|
||||
@property
|
||||
def lib(self):
|
||||
return self.home / "lib"
|
||||
|
||||
@property
|
||||
def lib_backup(self):
|
||||
return self.home / "lib-backup"
|
||||
|
||||
@property
|
||||
def data_dir(self): # type: () -> Path
|
||||
if self._data_dir is not None:
|
||||
return self._data_dir
|
||||
|
||||
from poetry.locations import data_dir
|
||||
|
||||
self._data_dir = data_dir()
|
||||
|
||||
return self._data_dir
|
||||
|
||||
@property
|
||||
def bin_dir(self): # type: () -> Path
|
||||
if self._data_dir is not None:
|
||||
return self._data_dir
|
||||
|
||||
from poetry.utils._compat import WINDOWS
|
||||
|
||||
if os.getenv("POETRY_HOME"):
|
||||
return Path(os.getenv("POETRY_HOME"), "bin").expanduser()
|
||||
|
||||
user_base = site.getuserbase()
|
||||
|
||||
if WINDOWS:
|
||||
bin_dir = os.path.join(user_base, "Scripts")
|
||||
else:
|
||||
bin_dir = os.path.join(user_base, "bin")
|
||||
|
||||
self._bin_dir = Path(bin_dir)
|
||||
|
||||
return self._bin_dir
|
||||
|
||||
@property
|
||||
def pool(self):
|
||||
if self._pool is not None:
|
||||
return self._pool
|
||||
|
||||
from poetry.repositories.pool import Pool
|
||||
from poetry.repositories.pypi_repository import PyPiRepository
|
||||
|
||||
pool = Pool()
|
||||
pool.add_repository(PyPiRepository(config=self.poetry.config, fallback=False))
|
||||
|
||||
self._pool = pool
|
||||
|
||||
return self._pool
|
||||
|
||||
def handle(self):
|
||||
from poetry.__version__ import __version__
|
||||
from poetry.core.semver import Version
|
||||
from poetry.utils.env import EnvManager
|
||||
|
||||
new_update_method = False
|
||||
try:
|
||||
self._check_recommended_installation()
|
||||
except RuntimeError as e:
|
||||
env = EnvManager.get_system_env(naive=True)
|
||||
try:
|
||||
env.path.relative_to(self.data_dir)
|
||||
except ValueError:
|
||||
raise e
|
||||
|
||||
new_update_method = True
|
||||
|
||||
version = self.argument("version")
|
||||
if not version:
|
||||
version = ">=" + __version__
|
||||
|
||||
repo = self.pool.repositories[0]
|
||||
packages = repo.find_packages(
|
||||
Dependency("poetry", version, allows_prereleases=self.option("preview"))
|
||||
)
|
||||
if not packages:
|
||||
self.line("No release found for the specified version")
|
||||
return
|
||||
|
||||
packages.sort(
|
||||
key=cmp_to_key(
|
||||
lambda x, y: 0
|
||||
if x.version == y.version
|
||||
else int(x.version < y.version or -1)
|
||||
)
|
||||
)
|
||||
|
||||
release = None
|
||||
for package in packages:
|
||||
if package.is_prerelease():
|
||||
if self.option("preview"):
|
||||
release = package
|
||||
|
||||
break
|
||||
|
||||
continue
|
||||
|
||||
release = package
|
||||
|
||||
break
|
||||
|
||||
if release is None:
|
||||
self.line("No new release found")
|
||||
return
|
||||
|
||||
if release.version == Version.parse(__version__):
|
||||
self.line("You are using the latest version")
|
||||
return
|
||||
|
||||
if new_update_method:
|
||||
return self.update_with_new_method(release.version)
|
||||
|
||||
self.update(release)
|
||||
|
||||
def update(self, release):
|
||||
version = release.version
|
||||
self.line("Updating to <info>{}</info>".format(version))
|
||||
|
||||
if self.lib_backup.exists():
|
||||
shutil.rmtree(str(self.lib_backup))
|
||||
|
||||
# Backup the current installation
|
||||
if self.lib.exists():
|
||||
shutil.copytree(str(self.lib), str(self.lib_backup))
|
||||
shutil.rmtree(str(self.lib))
|
||||
|
||||
try:
|
||||
self._update(version)
|
||||
except Exception:
|
||||
if not self.lib_backup.exists():
|
||||
raise
|
||||
|
||||
shutil.copytree(str(self.lib_backup), str(self.lib))
|
||||
shutil.rmtree(str(self.lib_backup))
|
||||
|
||||
raise
|
||||
finally:
|
||||
if self.lib_backup.exists():
|
||||
shutil.rmtree(str(self.lib_backup))
|
||||
|
||||
self.make_bin()
|
||||
|
||||
self.line("")
|
||||
self.line("")
|
||||
self.line(
|
||||
"<info>Poetry</info> (<comment>{}</comment>) is installed now. Great!".format(
|
||||
version
|
||||
)
|
||||
)
|
||||
|
||||
def update_with_new_method(self, version):
|
||||
self.line("Updating <c1>Poetry</c1> to <c2>{}</c2>".format(version))
|
||||
self.line("")
|
||||
|
||||
self._update_with_new_method(version)
|
||||
self._make_bin()
|
||||
|
||||
self.line("")
|
||||
self.line(
|
||||
"<c1>Poetry</c1> (<c2>{}</c2>) is installed now. Great!".format(version)
|
||||
)
|
||||
|
||||
def _update(self, version):
|
||||
from poetry.utils.helpers import temporary_directory
|
||||
|
||||
release_name = self._get_release_name(version)
|
||||
|
||||
checksum = "{}.sha256sum".format(release_name)
|
||||
|
||||
base_url = self.BASE_URL
|
||||
|
||||
try:
|
||||
r = urlopen(base_url + "/{}/{}".format(version, checksum))
|
||||
except HTTPError as e:
|
||||
if e.code == 404:
|
||||
raise RuntimeError("Could not find {} file".format(checksum))
|
||||
|
||||
raise
|
||||
|
||||
checksum = r.read().decode().strip()
|
||||
|
||||
# We get the payload from the remote host
|
||||
name = "{}.tar.gz".format(release_name)
|
||||
try:
|
||||
r = urlopen(base_url + "/{}/{}".format(version, name))
|
||||
except HTTPError as e:
|
||||
if e.code == 404:
|
||||
raise RuntimeError("Could not find {} file".format(name))
|
||||
|
||||
raise
|
||||
|
||||
meta = r.info()
|
||||
size = int(meta["Content-Length"])
|
||||
current = 0
|
||||
block_size = 8192
|
||||
|
||||
bar = self.progress_bar(max=size)
|
||||
bar.set_format(" - Downloading <info>{}</> <comment>%percent%%</>".format(name))
|
||||
bar.start()
|
||||
|
||||
sha = hashlib.sha256()
|
||||
with temporary_directory(prefix="poetry-updater-") as dir_:
|
||||
tar = os.path.join(dir_, name)
|
||||
with open(tar, "wb") as f:
|
||||
while True:
|
||||
buffer = r.read(block_size)
|
||||
if not buffer:
|
||||
break
|
||||
|
||||
current += len(buffer)
|
||||
f.write(buffer)
|
||||
sha.update(buffer)
|
||||
|
||||
bar.set_progress(current)
|
||||
|
||||
bar.finish()
|
||||
|
||||
# Checking hashes
|
||||
if checksum != sha.hexdigest():
|
||||
raise RuntimeError(
|
||||
"Hashes for {} do not match: {} != {}".format(
|
||||
name, checksum, sha.hexdigest()
|
||||
)
|
||||
)
|
||||
|
||||
gz = GzipFile(tar, mode="rb")
|
||||
try:
|
||||
with tarfile.TarFile(tar, fileobj=gz, format=tarfile.PAX_FORMAT) as f:
|
||||
f.extractall(str(self.lib))
|
||||
finally:
|
||||
gz.close()
|
||||
|
||||
def _update_with_new_method(self, version):
|
||||
from poetry.config.config import Config
|
||||
from poetry.core.packages.dependency import Dependency
|
||||
from poetry.core.packages.project_package import ProjectPackage
|
||||
from poetry.installation.installer import Installer
|
||||
from poetry.packages.locker import NullLocker
|
||||
from poetry.repositories.installed_repository import InstalledRepository
|
||||
from poetry.utils.env import EnvManager
|
||||
|
||||
env = EnvManager.get_system_env(naive=True)
|
||||
installed = InstalledRepository.load(env)
|
||||
|
||||
root = ProjectPackage("poetry-updater", "0.0.0")
|
||||
root.python_versions = ".".join(str(c) for c in env.version_info[:3])
|
||||
root.add_dependency(Dependency("poetry", version.text))
|
||||
|
||||
installer = Installer(
|
||||
self.io,
|
||||
env,
|
||||
root,
|
||||
NullLocker(self.data_dir.joinpath("poetry.lock"), {}),
|
||||
self.pool,
|
||||
Config(),
|
||||
installed=installed,
|
||||
)
|
||||
installer.update(True)
|
||||
installer.run()
|
||||
|
||||
def _make_bin(self):
|
||||
from poetry.utils._compat import WINDOWS
|
||||
|
||||
self.line("")
|
||||
self.line("Updating the <c1>poetry</c1> script")
|
||||
|
||||
self.bin_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
script = "poetry"
|
||||
target_script = "venv/bin/poetry"
|
||||
if WINDOWS:
|
||||
script = "poetry.exe"
|
||||
target_script = "venv/Scripts/poetry.exe"
|
||||
|
||||
if self.bin_dir.joinpath(script).exists():
|
||||
self.bin_dir.joinpath(script).unlink()
|
||||
|
||||
if not PY2 and not WINDOWS:
|
||||
try:
|
||||
self.bin_dir.joinpath(script).symlink_to(
|
||||
self.data_dir.joinpath(target_script)
|
||||
)
|
||||
except OSError:
|
||||
# This can happen if the user
|
||||
# does not have the correct permission on Windows
|
||||
shutil.copy(
|
||||
self.data_dir.joinpath(target_script), self.bin_dir.joinpath(script)
|
||||
)
|
||||
else:
|
||||
shutil.copy(
|
||||
str(self.data_dir.joinpath(target_script)),
|
||||
str(self.bin_dir.joinpath(script)),
|
||||
)
|
||||
|
||||
def process(self, *args):
|
||||
return subprocess.check_output(list(args), stderr=subprocess.STDOUT)
|
||||
|
||||
def _check_recommended_installation(self):
|
||||
from poetry.utils._compat import Path
|
||||
|
||||
current = Path(__file__)
|
||||
try:
|
||||
current.relative_to(self.home)
|
||||
except ValueError:
|
||||
raise RuntimeError(
|
||||
"Poetry was not installed with the recommended installer. "
|
||||
"Cannot update automatically."
|
||||
)
|
||||
|
||||
def _get_release_name(self, version):
|
||||
platform = sys.platform
|
||||
if platform == "linux2":
|
||||
platform = "linux"
|
||||
|
||||
return "poetry-{}-{}".format(version, platform)
|
||||
|
||||
def _bin_path(self, base_path, bin):
|
||||
from poetry.utils._compat import WINDOWS
|
||||
|
||||
if WINDOWS:
|
||||
return (base_path / "Scripts" / bin).with_suffix(".exe")
|
||||
|
||||
return base_path / "bin" / bin
|
||||
|
||||
def make_bin(self):
|
||||
from poetry.utils._compat import WINDOWS
|
||||
|
||||
self.bin.mkdir(0o755, parents=True, exist_ok=True)
|
||||
|
||||
python_executable = self._which_python()
|
||||
|
||||
if WINDOWS:
|
||||
with self.bin.joinpath("poetry.bat").open("w", newline="") as f:
|
||||
f.write(
|
||||
BAT.format(
|
||||
python_executable=python_executable,
|
||||
poetry_bin=str(self.bin / "poetry").replace(
|
||||
os.environ["USERPROFILE"], "%USERPROFILE%"
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
bin_content = BIN
|
||||
if not WINDOWS:
|
||||
bin_content = "#!/usr/bin/env {}\n".format(python_executable) + bin_content
|
||||
|
||||
self.bin.joinpath("poetry").write_text(bin_content, encoding="utf-8")
|
||||
|
||||
if not WINDOWS:
|
||||
# Making the file executable
|
||||
st = os.stat(str(self.bin.joinpath("poetry")))
|
||||
os.chmod(str(self.bin.joinpath("poetry")), st.st_mode | stat.S_IEXEC)
|
||||
|
||||
def _which_python(self):
|
||||
"""
|
||||
Decides which python executable we'll embed in the launcher script.
|
||||
"""
|
||||
from poetry.utils._compat import WINDOWS
|
||||
|
||||
allowed_executables = ["python", "python3"]
|
||||
if WINDOWS:
|
||||
allowed_executables += ["py.exe -3", "py.exe -2"]
|
||||
|
||||
# \d in regex ensures we can convert to int later
|
||||
version_matcher = re.compile(r"^Python (?P<major>\d+)\.(?P<minor>\d+)\..+$")
|
||||
fallback = None
|
||||
for executable in allowed_executables:
|
||||
try:
|
||||
raw_version = subprocess.check_output(
|
||||
executable + " --version", stderr=subprocess.STDOUT, shell=True
|
||||
).decode("utf-8")
|
||||
except subprocess.CalledProcessError:
|
||||
continue
|
||||
|
||||
match = version_matcher.match(raw_version.strip())
|
||||
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
|
||||
|
||||
if fallback is None:
|
||||
# Avoid breaking existing scripts
|
||||
fallback = "python"
|
||||
|
||||
return fallback
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e7/66/08/3a9853a67e4f6f6c36790e201dd2b78bbebe967419a556ab3f46a92004
|
1
venv/lib/python3.8/site-packages/poetry/console/commands/show.py
Symbolic link
1
venv/lib/python3.8/site-packages/poetry/console/commands/show.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e6/46/af/44aa90700845448421ec2db03db81e1824fb2a8ca61751042f9add09d0
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/71/fb/dc/ddd9d4c4d76c4a0959ece9968a38e3b0429b9b6157ec9afb70da86d584
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/44/5e/c8/406eb1b07061704a737a1a2a6cab1b0b9c8448815771caf9cba8df31ea
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/ce/2f/76/267701c530583bbfcfccb985eb6a2005d9e2ad8ce9f55662076e8a1e32
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/84/1f/ec/e568ca8230d16a9a25ec7f0952ed12de20831ffb0f56d19fb40837656b
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/e3/b0/c4/4298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/f5/c4/1f/7f9085694660e50252899bc42c821cf26c0b19a34c15a74ef6e58cefc3
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/a3/56/bc/54f390100fb2252f935bb32d496b9bb96c9bd0434316d752d0c79f23cc
|
|
@ -0,0 +1 @@
|
|||
/home/runner/.cache/pip/pool/f8/a7/8b/459b7d53107b95fe33194b8b2ac6b687319c24771330a43eaa63b3e2cb
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue