|
8 | 8 | import subprocess |
9 | 9 | import sys |
10 | 10 | import time |
| 11 | +from functools import partial |
11 | 12 | from pathlib import Path |
12 | 13 |
|
13 | 14 | from aiosmtpd import __version__ as version |
14 | 15 |
|
| 16 | +printfl = partial(print, flush=True) |
| 17 | +run_hidden = partial(subprocess.run, stdout=subprocess.PIPE) |
| 18 | + |
15 | 19 | TWINE_CONFIG = Path(os.environ.get("TWINE_CONFIG", "~/.pypirc")).expanduser() |
16 | 20 | TWINE_REPO = os.environ.get("TWINE_REPOSITORY", "aiosmtpd") |
17 | 21 | UPSTREAM_REMOTE = os.environ.get("UPSTREAM_REMOTE", "upstream") |
|
21 | 25 | f"dist/aiosmtpd-{version}-py3-none-any.whl", |
22 | 26 | ] |
23 | 27 |
|
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() |
28 | 37 | if b"\ntwine-verify-upload==" not in result.stdout: |
29 | 38 | print("*** Package twine-verify-upload is not yet installed.") |
30 | 39 | print("*** Consider installing it. It is very useful :)") |
|
62 | 71 | sys.exit("Release aborted") |
63 | 72 |
|
64 | 73 | 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) |
67 | 87 |
|
68 | 88 | # We're probably already in the right place |
69 | 89 | os.chdir(Path(__file__).absolute().parent) |
|
88 | 108 | if has_verify: |
89 | 109 | print("Waiting for package to be received by PyPI...", end="") |
90 | 110 | for i in range(10, 0, -1): |
91 | | - print(i, end="..", flush=True) |
| 111 | + printfl(i, end="..") |
92 | 112 | time.sleep(1.0) |
93 | 113 | print() |
94 | 114 | twine_verif = ["twine", "verify_upload"] + DISTFILES |
|
0 commit comments