-
Notifications
You must be signed in to change notification settings - Fork 1
/
publish.py
31 lines (23 loc) · 796 Bytes
/
publish.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
"""Publish package to PyPI."""
import shlex
import shutil
import subprocess
PKG_NAME = "mettoolbox"
with open("VERSION", encoding="ascii") as version_file:
version = version_file.readline().strip()
shutil.rmtree("build", ignore_errors=True)
subprocess.run(shlex.split("pyclean ."), check=True)
subprocess.run(shlex.split("python3 -m build --sdist"), check=True)
subprocess.run(shlex.split("python3 -m build --wheel"), check=True)
sdist = f"dist/{PKG_NAME}-{version}.tar.gz"
wheel = f"dist/{PKG_NAME}-{version}*.whl"
for file in [sdist, wheel]:
subprocess.run(
shlex.split(f"twine check {file}"),
check=True,
)
subprocess.run(
shlex.split(f"twine upload --skip-existing {file}"),
check=True,
)
shutil.rmtree("build", ignore_errors=True)