-
Notifications
You must be signed in to change notification settings - Fork 9
/
pull_packages.py
47 lines (34 loc) · 1.04 KB
/
pull_packages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import json
import logging
import sys
from pathlib import Path
from oras import Oras
owner = sys.argv[1]
target_platform = str(sys.argv[2])
conda_prefix = sys.argv[3]
token = sys.argv[4]
directory = "conda-bld"
oras = Oras(owner, token, conda_prefix, target_platform)
oras.login()
base = Path(conda_prefix) / directory
if not base.is_dir():
logging.warning(f" {base} did NOT exist")
base.mkdir(mode=511, parents=False, exist_ok=True)
if "win" in target_platform:
target_platform = "win"
path = base / target_platform
if not path.is_dir:
path.mkdir(mode=511, parents=False, exist_ok=True)(f" {base} did NOT exist")
trgt = "linux"
if "osx" in target_platform:
trgt = "osx"
elif "win" in target_platform:
trgt = "win"
with open("packages.json", "r") as read_file:
packages_json = json.load(read_file)
packagesList = packages_json["pkgs"][trgt]
versions_dict = {}
for pkg in packagesList:
versions_dict = oras.pull(pkg, "latest", str(path), versions_dict)
with open("versions.json", "w") as fp:
json.dump(versions_dict, fp)