mirror of
https://github.com/clearml/clearml-agent
synced 2025-06-08 15:38:06 +00:00
Fix pip support allowing multiple pip version constraints (by default, one for <PY3.10 and one for >=PY3.10)
This commit is contained in:
parent
dd75cedaab
commit
ca2791c65e
@ -66,7 +66,7 @@
|
|||||||
type: pip,
|
type: pip,
|
||||||
|
|
||||||
# specify pip version to use (examples "<20.2", "==19.3.1", "", empty string will install the latest version)
|
# specify pip version to use (examples "<20.2", "==19.3.1", "", empty string will install the latest version)
|
||||||
pip_version: "<21",
|
pip_version: ["<20.2 ; python_version < '3.10'", "<22.3 ; python_version >= '3.10'"],
|
||||||
# specify poetry version to use (examples "<2", "==1.1.1", "", empty string will install the latest version)
|
# specify poetry version to use (examples "<2", "==1.1.1", "", empty string will install the latest version)
|
||||||
# poetry_version: "<2",
|
# poetry_version: "<2",
|
||||||
|
|
||||||
|
@ -3875,10 +3875,10 @@ class Worker(ServiceCommandSection):
|
|||||||
update_scheme += (
|
update_scheme += (
|
||||||
docker_bash_script + " ; " +
|
docker_bash_script + " ; " +
|
||||||
"[ ! -z $LOCAL_PYTHON ] || export LOCAL_PYTHON={python} ; " +
|
"[ ! -z $LOCAL_PYTHON ] || export LOCAL_PYTHON={python} ; " +
|
||||||
"$LOCAL_PYTHON -m pip install -U \"pip{pip_version}\" ; " +
|
"$LOCAL_PYTHON -m pip install -U {pip_version} ; " +
|
||||||
"$LOCAL_PYTHON -m pip install -U {clearml_agent_wheel} ; ").format(
|
"$LOCAL_PYTHON -m pip install -U {clearml_agent_wheel} ; ").format(
|
||||||
python_single_digit=python_version.split('.')[0],
|
python_single_digit=python_version.split('.')[0],
|
||||||
python=python_version, pip_version=PackageManager.get_pip_version(),
|
python=python_version, pip_version=" ".join(PackageManager.get_pip_versions(wrap='\"')),
|
||||||
clearml_agent_wheel=clearml_agent_wheel,
|
clearml_agent_wheel=clearml_agent_wheel,
|
||||||
mount_ssh_ro=mount_ssh_ro, mount_ssh=mount_ssh,
|
mount_ssh_ro=mount_ssh_ro, mount_ssh=mount_ssh,
|
||||||
)
|
)
|
||||||
|
@ -80,7 +80,12 @@ class PackageManager(object):
|
|||||||
|
|
||||||
def upgrade_pip(self):
|
def upgrade_pip(self):
|
||||||
result = self._install(
|
result = self._install(
|
||||||
select_for_platform(windows='pip{}', linux='pip{}').format(self.get_pip_version()), "--upgrade")
|
*select_for_platform(
|
||||||
|
windows=self.get_pip_versions(),
|
||||||
|
linux=self.get_pip_versions()
|
||||||
|
),
|
||||||
|
"--upgrade"
|
||||||
|
)
|
||||||
packages = self.run_with_env(('list',), output=True).splitlines()
|
packages = self.run_with_env(('list',), output=True).splitlines()
|
||||||
# p.split is ('pip', 'x.y.z')
|
# p.split is ('pip', 'x.y.z')
|
||||||
pip = [p.split() for p in packages if len(p.split()) == 2 and p.split()[0] == 'pip']
|
pip = [p.split() for p in packages if len(p.split()) == 2 and p.split()[0] == 'pip']
|
||||||
@ -157,15 +162,26 @@ class PackageManager(object):
|
|||||||
def set_pip_version(cls, version):
|
def set_pip_version(cls, version):
|
||||||
if not version:
|
if not version:
|
||||||
return
|
return
|
||||||
version = version.replace(' ', '')
|
|
||||||
if ('=' in version) or ('~' in version) or ('<' in version) or ('>' in version):
|
if isinstance(version, (list, tuple)):
|
||||||
cls._pip_version = version
|
versions = version
|
||||||
else:
|
else:
|
||||||
cls._pip_version = "=="+version
|
versions = [version]
|
||||||
|
|
||||||
|
cls._pip_version = []
|
||||||
|
for version in versions:
|
||||||
|
version = version.strip()
|
||||||
|
if ('=' in version) or ('~' in version) or ('<' in version) or ('>' in version):
|
||||||
|
cls._pip_version.append(version)
|
||||||
|
else:
|
||||||
|
cls._pip_version.append("==" + version)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_pip_version(cls):
|
def get_pip_versions(cls, pip="pip", wrap='"'):
|
||||||
return cls._pip_version or ''
|
return [
|
||||||
|
(wrap + pip + version + wrap)
|
||||||
|
for version in cls._pip_version or [pip]
|
||||||
|
]
|
||||||
|
|
||||||
def get_cached_venv(self, requirements, docker_cmd, python_version, cuda_version, destination_folder):
|
def get_cached_venv(self, requirements, docker_cmd, python_version, cuda_version, destination_folder):
|
||||||
# type: (Dict, Optional[Union[dict, str]], Optional[str], Optional[str], Path) -> Optional[Path]
|
# type: (Dict, Optional[Union[dict, str]], Optional[str], Optional[str], Path) -> Optional[Path]
|
||||||
|
@ -135,7 +135,12 @@ class CondaAPI(PackageManager):
|
|||||||
if self.env_read_only:
|
if self.env_read_only:
|
||||||
print('Conda environment in read-only mode, skipping pip upgrade.')
|
print('Conda environment in read-only mode, skipping pip upgrade.')
|
||||||
return ''
|
return ''
|
||||||
return self._install(select_for_platform(windows='pip{}', linux='pip{}').format(self.pip.get_pip_version()))
|
return self._install(
|
||||||
|
*select_for_platform(
|
||||||
|
windows=self.pip.get_pip_versions(),
|
||||||
|
linux=self.pip.get_pip_versions()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"""
|
"""
|
||||||
|
@ -79,7 +79,7 @@ agent {
|
|||||||
type: pip,
|
type: pip,
|
||||||
|
|
||||||
# specify pip version to use (examples "<20.2", "==19.3.1", "", empty string will install the latest version)
|
# specify pip version to use (examples "<20.2", "==19.3.1", "", empty string will install the latest version)
|
||||||
# pip_version: "<21"
|
# pip_version: ["<20.2 ; python_version < '3.10'", "<22.3 ; python_version >= '3.10'"]
|
||||||
# specify poetry version to use (examples "<2", "==1.1.1", "", empty string will install the latest version)
|
# specify poetry version to use (examples "<2", "==1.1.1", "", empty string will install the latest version)
|
||||||
# poetry_version: "<2",
|
# poetry_version: "<2",
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user