forked from sohailc/qcodes-sweep
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload.py
45 lines (31 loc) · 1.05 KB
/
upload.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
import os
import re
import subprocess
from collections import defaultdict
def make():
command = "python setup.py bdist_wheel"
p = subprocess.Popen(command)
p.communicate()
def get_latest(version_list):
major_version_dict = defaultdict(list)
for version in version_list:
major, minor = version.split(".")
major_version_dict[major].append(minor)
max_major = sorted(major_version_dict.keys())[-1]
max_minor = sorted(major_version_dict[max_major])[-1]
return "{}.{}".format(max_major, max_minor)
def upload():
dist_files = os.listdir("dist")
versions = {}
for file_name in dist_files:
result = re.search("pysweep2-([0-9]*\.[0-9]*).+", file_name)
if result is not None:
versions[result.groups()[0]] = file_name
latest_version = get_latest(versions.keys())
latest_file = versions[latest_version]
command = "twine upload dist{}{}".format(os.path.sep, latest_file)
print("Please run the command:")
print(command)
if __name__ == "__main__":
make()
upload()