rename_wheel.py 576 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os
import os.path as osp
import glob

dist_dir = osp.join(osp.dirname(osp.abspath(__file__)), '..', 'dist')
wheels = glob.glob(osp.join('dist', '**', '*.whl'), recursive=True)

for wheel in wheels:
    idx = wheel.split(osp.sep)[-2]
    if idx not in ['cpu', 'cu92', 'cu100', 'cu101']:
        continue
    name = wheel.split(osp.sep)[-1]
    if idx in name:
        continue

    names = name.split('-')
    name = '-'.join(names[:-4] + [names[-4] + '%2B' + idx] + names[-3:])
    new_wheel = osp.join(*wheel.split(osp.sep)[:-1], name)
    os.rename(wheel, new_wheel)