7
"""Script which downloads wheel files hosted on GitHub:
8
https://github.com/giampaolo/psutil/actions
9
It needs an access token string generated from personal GitHub profile:
10
https://github.com/settings/tokens
11
The token must be created with at least "public_repo" scope/rights.
12
If you lose it, just generate a new token.
14
https://developer.github.com/v3/actions/artifacts/.
25
from psutil import __version__
26
from psutil._common import bytes2human
27
from psutil.tests import safe_rmpath
32
PROJECT_VERSION = __version__
33
OUTFILE = "wheels-github.zip"
39
base_url = "https://api.github.com/repos/%s/%s" % (USER, PROJECT)
40
url = base_url + "/actions/artifacts"
42
url=url, headers={"Authorization": "token %s" % TOKEN}, timeout=TIMEOUT
44
res.raise_for_status()
45
data = json.loads(res.content)
50
print("downloading: " + url)
52
url=url, headers={"Authorization": "token %s" % TOKEN}, timeout=TIMEOUT
54
res.raise_for_status()
56
with open(OUTFILE, 'wb') as f:
57
for chunk in res.iter_content(chunk_size=16384):
59
totbytes += len(chunk)
60
print("got %s, size %s)" % (OUTFILE, bytes2human(totbytes)))
63
def rename_win27_wheels():
65
src = 'dist/psutil-%s-cp27-cp27m-win32.whl' % PROJECT_VERSION
66
dst = 'dist/psutil-%s-cp27-none-win32.whl' % PROJECT_VERSION
67
if os.path.exists(src):
68
print("rename: %s\n %s" % (src, dst))
70
src = 'dist/psutil-%s-cp27-cp27m-win_amd64.whl' % PROJECT_VERSION
71
dst = 'dist/psutil-%s-cp27-none-win_amd64.whl' % PROJECT_VERSION
72
if os.path.exists(src):
73
print("rename: %s\n %s" % (src, dst))
78
data = get_artifacts()
79
download_zip(data['artifacts'][0]['archive_download_url'])
80
os.makedirs('dist', exist_ok=True)
81
with zipfile.ZipFile(OUTFILE, 'r') as zf:
88
parser = argparse.ArgumentParser(description='GitHub wheels downloader')
89
parser.add_argument('--token')
90
parser.add_argument('--tokenfile')
91
args = parser.parse_args()
94
with open(os.path.expanduser(args.tokenfile)) as f:
95
TOKEN = f.read().strip()
99
return sys.exit('specify --token or --tokenfile args')
107
if __name__ == '__main__':