diff --git a/bench/app.py b/bench/app.py index 37ba560a..c750b18f 100755 --- a/bench/app.py +++ b/bench/app.py @@ -215,17 +215,26 @@ class App(AppMeta): self.bench.run(f"{self.bench.python} -m pip uninstall -y {self.repo}") def _get_dependencies(self): - from bench.utils.app import get_required_deps_url + from bench.utils.app import get_required_deps - required_url = get_required_deps_url(git_url=self.url, repo_name=self.repo, branch=self.tag) try: - f = requests.get(required_url).text - lines = [x for x in f.split("\n") if x.strip().startswith("required_apps")] - required_apps = eval(lines[0].strip("required_apps").strip().lstrip("=").strip()) - return required_apps + required_deps = get_required_deps( + self.org, self.repo, self.tag or self.branch + ) + lines = [ + x + for x in required_deps.split("\n") + if x.strip().startswith("required_apps") + ] + required_apps = eval( + lines[0].strip("required_apps").strip().lstrip("=").strip() + ) except Exception: return [] + return required_apps + + def make_resolution_plan(app: App, bench: "Bench"): """ decide what apps and versions to install and in what order diff --git a/bench/utils/app.py b/bench/utils/app.py index e86a0304..6d5f0f32 100644 --- a/bench/utils/app.py +++ b/bench/utils/app.py @@ -164,13 +164,15 @@ def get_current_branch(app, bench_path="."): repo_dir = get_repo_dir(app, bench_path=bench_path) return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir) -def get_required_deps_url(git_url, repo_name, branch, deps="hooks.py"): - git_url = ( - git_url.replace(".git", "").replace("github.com", "raw.github.com") - ) - branch = branch if branch else "develop" - git_url += f"/{branch}/{repo_name}/{deps}" - return git_url +def get_required_deps(org, name, branch, deps="hooks.py"): + import requests + import base64 + + url = f"https://api.github.com/repos/{org}/{name}/contents/{name}/{deps}" + params = {"branch": branch or "develop"} + res = requests.get(url=url, params=params).json() + return base64.decodebytes(res["content"].encode()).decode() + def get_remote(app, bench_path="."): repo_dir = get_repo_dir(app, bench_path=bench_path)