ensure_dependencies. Route handler or application helper. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 105 | """ |
| 106 | if isinstance(pkgs, str): |
| 107 | pkgs = [pkgs] |
| 108 | _bash("pkg update -y", capture=False) |
| 109 | _bash("pkg install -y " + " ".join(pkgs), capture=False) |
| 110 | |
| 111 | def ensure_dependencies(): |
| 112 | # flask + werkzeug included with flask |
| 113 | """ensure_dependencies. |
| 114 | |
| 115 | Route handler or application helper. |
| 116 | |
| 117 | This docstring was expanded to make future maintenance easier. |
| 118 | |
| 119 | Returns: |
| 120 | Varies. |
| 121 | """ |
| 122 | # flask + werkzeug included with flask |
| 123 | try: |
| 124 | import flask # noqa |
| 125 | except Exception: |
| 126 | _run([sys.executable, "-m", "pip", "install", "--upgrade", "pip", "setuptools", "wheel"], check=False) |
| 127 | _run([sys.executable, "-m", "pip", "install", "flask>=2.3"], check=False) |
| 128 | |
| 129 | # cryptography (prefer termux package) |
| 130 | try: |
| 131 | import cryptography # noqa |
| 132 | except Exception: |
| 133 | if _is_termux(): |
| 134 | _termux_pkg_install(["python-cryptography", "openssl"]) |
| 135 | try: |
| 136 | import cryptography # noqa |
| 137 | except Exception: |
| 138 | env = os.environ.copy() |
| 139 | if _is_termux() and "ANDROID_API_LEVEL" not in env: |
| 140 | try: |
| 141 | sdk = subprocess.check_output(["getprop", "ro.build.version.sdk"], text=True).strip() |
| 142 | if sdk.isdigit(): |
| 143 | env["ANDROID_API_LEVEL"] = sdk |
| 144 | except Exception: |
| 145 | pass |
no test coverage detected