2019-10-25 19:28:44 +00:00
|
|
|
from typing import Text
|
|
|
|
|
|
|
|
from .base import PackageManager
|
|
|
|
from .requirements import SimpleSubstitution
|
|
|
|
|
|
|
|
|
|
|
|
class HorovodRequirement(SimpleSubstitution):
|
|
|
|
|
|
|
|
name = "horovod"
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(HorovodRequirement, self).__init__(*args, **kwargs)
|
|
|
|
self.post_install_req = None
|
|
|
|
|
|
|
|
def match(self, req):
|
|
|
|
# match both horovod
|
2020-01-14 09:37:41 +00:00
|
|
|
return req.name and self.name == req.name.lower()
|
2019-10-25 19:28:44 +00:00
|
|
|
|
2020-06-17 22:55:14 +00:00
|
|
|
def post_install(self, session):
|
2019-10-25 19:28:44 +00:00
|
|
|
if self.post_install_req:
|
|
|
|
PackageManager.out_of_scope_install_package(self.post_install_req.tostr(markers=False))
|
|
|
|
self.post_install_req = None
|
|
|
|
|
|
|
|
def replace(self, req):
|
|
|
|
"""
|
|
|
|
Replace a requirement
|
|
|
|
:raises: ValueError if version is pre-release
|
|
|
|
"""
|
|
|
|
# Store in post req install, and return nothing
|
|
|
|
self.post_install_req = req
|
|
|
|
# mark skip package, we will install it in post install hook
|
|
|
|
return Text('')
|