Skip to content

Commit a9e8d6f

Browse files
committed
Enhance release.py
* Now ensures release toolkit is up-to-date * If tox run selected, the default testenvs are "qa,docs"
1 parent 986127f commit a9e8d6f

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

release.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88
import subprocess
99
import sys
1010
import time
11+
from functools import partial
1112
from pathlib import Path
1213

1314
from aiosmtpd import __version__ as version
1415

16+
printfl = partial(print, flush=True)
17+
run_hidden = partial(subprocess.run, stdout=subprocess.PIPE)
18+
1519
TWINE_CONFIG = Path(os.environ.get("TWINE_CONFIG", "~/.pypirc")).expanduser()
1620
TWINE_REPO = os.environ.get("TWINE_REPOSITORY", "aiosmtpd")
1721
UPSTREAM_REMOTE = os.environ.get("UPSTREAM_REMOTE", "upstream")
@@ -21,10 +25,15 @@
2125
f"dist/aiosmtpd-{version}-py3-none-any.whl",
2226
]
2327

24-
result = subprocess.run(["pip", "freeze"], stdout=subprocess.PIPE)
25-
if b"\ntwine==" not in result.stdout:
26-
print("ERROR: twine not installed. Please install 'twine' first")
27-
sys.exit(1)
28+
printfl("Updating release toolkit first...", end="")
29+
run_hidden(
30+
[sys.executable] + "-m pip install -U setuptools wheel twine".split()
31+
)
32+
print()
33+
34+
printfl("Checking extra toolkit...", end="")
35+
result = run_hidden([sys.executable] + "-m pip freeze".split())
36+
print()
2837
if b"\ntwine-verify-upload==" not in result.stdout:
2938
print("*** Package twine-verify-upload is not yet installed.")
3039
print("*** Consider installing it. It is very useful :)")
@@ -62,8 +71,19 @@
6271
sys.exit("Release aborted")
6372

6473
choice = input("Run tox first? [y/N]: ")
65-
if choice.lower() in ("y", "yes"):
66-
subprocess.run("tox")
74+
if choice.casefold() in ("y", "yes"):
75+
choice = input(" All testenvs? [y/N]: ")
76+
try:
77+
if choice.lower() in ("y", "yes"):
78+
printfl("Running tox, all testenvs. This will take some time...", end="")
79+
run_hidden("tox")
80+
else:
81+
printfl("Running 'tox -e qa,docs', please wait...", end="")
82+
run_hidden("tox -e qa,docs".split())
83+
print()
84+
except subprocess.CalledProcessError:
85+
print("ERROR: tox failed. Please run all tests")
86+
sys.exit(1)
6787

6888
# We're probably already in the right place
6989
os.chdir(Path(__file__).absolute().parent)
@@ -88,7 +108,7 @@
88108
if has_verify:
89109
print("Waiting for package to be received by PyPI...", end="")
90110
for i in range(10, 0, -1):
91-
print(i, end="..", flush=True)
111+
printfl(i, end="..")
92112
time.sleep(1.0)
93113
print()
94114
twine_verif = ["twine", "verify_upload"] + DISTFILES

0 commit comments

Comments
 (0)