wheel.py 1.46 KB
Newer Older
rusty1s's avatar
windows  
rusty1s committed
1
2
3
4
5
import boto3

s3_resource = boto3.resource('s3')
bucket = s3_resource.Bucket(name="pytorch-scatter")
objects = bucket.objects.all()
rusty1s's avatar
rusty1s committed
6
wheels = sorted([obj.key for obj in objects if obj.key[-3:] == 'whl'])
rusty1s's avatar
windows  
rusty1s committed
7

rusty1s's avatar
rusty1s committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
wheels_dict = {}
for torch_version in list(set([wheel.split('/')[1] for wheel in wheels])):
    wheels_dict[torch_version] = []

for wheel in wheels:
    torch_version = wheel.split('/')[1]
    wheels_dict[torch_version].append(wheel)

html = '<!DOCTYPE html>\n<html>\n<body>\n{}\n</body>\n</html>'
href = '<a href="{}">{}</a><br/>'

url = 'http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/{}.html'
index_html = html.format('\n'.join([
    href.format(url.format('whl/' + key), key) for key in wheels_dict.keys()
]))
rusty1s's avatar
rusty1s committed
23
24

with open('index.html', 'w') as f:
rusty1s's avatar
rusty1s committed
25
    f.write(index_html)
rusty1s's avatar
rusty1s committed
26

rusty1s's avatar
typo  
rusty1s committed
27
28
29
30
31
bucket.Object('whl/index.html').upload_file(
    Filename='index.html', ExtraArgs={
        'ContentType': 'text/html',
        'ACL': 'public-read'
    })
rusty1s's avatar
rusty1s committed
32
33
34
35

url = 'https://pytorch-scatter.s3.eu-central-1.amazonaws.com/{}'
for key, item in wheels_dict.items():
    version_html = html.format('\n'.join([
rusty1s's avatar
fix url  
rusty1s committed
36
37
        href.format(url.format(i.replace('+', '%2B')),
                    '/'.join(i.split('/')[2:])) for i in item
rusty1s's avatar
rusty1s committed
38
39
40
41
42
43
44
45
46
47
    ]))

    with open('{}.html'.format(key), 'w') as f:
        f.write(version_html)

    bucket.Object('whl/{}.html'.format(key)).upload_file(
        Filename='{}.html'.format(key), ExtraArgs={
            'ContentType': 'text/html',
            'ACL': 'public-read'
        })