mirror of
https://github.com/clearml/clearml-agent
synced 2025-02-07 21:35:00 +00:00
Add support for detecting new pip version (20+) supporting @ in requirements
This commit is contained in:
parent
7170296162
commit
c7a739fafa
@ -66,7 +66,19 @@ class PackageManager(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def upgrade_pip(self):
|
def upgrade_pip(self):
|
||||||
return self._install("pip"+self.get_pip_version(), "--upgrade")
|
result = self._install("pip"+self.get_pip_version(), "--upgrade")
|
||||||
|
packages = self.run_with_env(('list',), output=True).splitlines()
|
||||||
|
# p.split is ('pip', 'x.y.z')
|
||||||
|
pip = [p.split() for p in packages if len(p.split()) == 2 and p.split()[0] == 'pip']
|
||||||
|
if pip:
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
from .requirements import MarkerRequirement
|
||||||
|
pip = pip[0][1].split('.')
|
||||||
|
MarkerRequirement.pip_new_version = bool(int(pip[0]) >= 20)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return result
|
||||||
|
|
||||||
def get_python_command(self, extra=()):
|
def get_python_command(self, extra=()):
|
||||||
# type: (...) -> Executable
|
# type: (...) -> Executable
|
||||||
|
@ -35,6 +35,10 @@ class FatalSpecsResolutionError(Exception):
|
|||||||
@six.python_2_unicode_compatible
|
@six.python_2_unicode_compatible
|
||||||
class MarkerRequirement(object):
|
class MarkerRequirement(object):
|
||||||
|
|
||||||
|
# if True pip version above 20.x and with support for "package @ scheme://link"
|
||||||
|
# default is True
|
||||||
|
pip_new_version = True
|
||||||
|
|
||||||
def __init__(self, req): # type: (Requirement) -> None
|
def __init__(self, req): # type: (Requirement) -> None
|
||||||
self.req = req
|
self.req = req
|
||||||
|
|
||||||
@ -65,6 +69,10 @@ class MarkerRequirement(object):
|
|||||||
'@{}'.format(self.revision) if self.revision else '',
|
'@{}'.format(self.revision) if self.revision else '',
|
||||||
'#subdirectory={}'.format(self.subdirectory) if self.subdirectory else ''
|
'#subdirectory={}'.format(self.subdirectory) if self.subdirectory else ''
|
||||||
]
|
]
|
||||||
|
elif self.pip_new_version and self.uri and self.name and self.line:
|
||||||
|
# package @ https://example.com/somewheel.whl
|
||||||
|
# leave the line as is, let pip handle it
|
||||||
|
return self.line
|
||||||
else:
|
else:
|
||||||
parts = [self.uri]
|
parts = [self.uri]
|
||||||
|
|
||||||
@ -492,6 +500,9 @@ class RequirementsManager(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def replace_back(self, requirements):
|
def replace_back(self, requirements):
|
||||||
|
if self.translator:
|
||||||
|
requirements = self.translator.replace_back(requirements)
|
||||||
|
|
||||||
for h in self.handlers:
|
for h in self.handlers:
|
||||||
try:
|
try:
|
||||||
requirements = h.replace_back(requirements)
|
requirements = h.replace_back(requirements)
|
||||||
|
Loading…
Reference in New Issue
Block a user