File size: 1,123 Bytes
9b5db35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from utils import read_jsonl
import os
import argparse
import subprocess


def download_py_dependencies(repo_path: str, install_cmd: str) -> bool:
    result = subprocess.run(
        install_cmd,
        shell=True,
        text=True,
        executable='/bin/bash',
        cwd=repo_path,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
    return result.returncode == 0


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--repo_cache_dir', type=str, default='/tmp/pywork1/py500')
    args = parser.parse_args()
    py500 = read_jsonl('data/py500.jsonl')
    repos = set()
    for i, data in enumerate(py500):
        print(f'=== {i} ===')
        if repos.__contains__(data['repo_name']):
            print(f'Skip {i}')
            continue
        repo_path = str(os.path.join(
            args.repo_cache_dir,
            data['repo_name']
        ))
        res = download_py_dependencies(
            repo_path=repo_path,
            install_cmd=data['install_cmd'],
        )
        print(res)
        repos.add(data['repo_name'])
        assert res