Download common/package_manager.py from hhz520/webchat: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/hhz520/webchat/resolve/main/common/package_manager.py
- Command line
-
hf download hf://spaces/hhz520/webchat/common/package_manager.py
-
curl -L -o package_manager.py https://huggingface.co/spaces/hhz520/webchat/resolve/main/common/package_manager.py
725 Bytes
| import time | |
| import pip | |
| from pip._internal import main as pipmain | |
| from common.log import _reset_logger, logger | |
| def install(package): | |
| pipmain(["install", package]) | |
| def install_requirements(file): | |
| pipmain(["install", "-r", file, "--upgrade"]) | |
| _reset_logger(logger) | |
| def check_dulwich(): | |
| needwait = False | |
| for i in range(2): | |
| if needwait: | |
| time.sleep(3) | |
| needwait = False | |
| try: | |
| import dulwich | |
| return | |
| except ImportError: | |
| try: | |
| install("dulwich") | |
| except: | |
| needwait = True | |
| try: | |
| import dulwich | |
| except ImportError: | |
| raise ImportError("Unable to import dulwich") | |