-
Notifications
You must be signed in to change notification settings - Fork 17
/
publish.py
37 lines (28 loc) · 931 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
32
33
34
35
36
37
"""
Publish package to PyPI.
This script is used to publish the package to PyPI. It is a simple script that
uses the `build` module to create the source distribution and wheel, and then
uses `twine` to upload the package to PyPI.
Need to install the following packages:
- build (if using PyPI), python-build (if using conda-forge)
- twine
"""
import shlex
import shutil
import subprocess
PKG_NAME = "hsp2"
with open("VERSION", encoding="ascii") as version_file:
version = version_file.readline().strip()
shutil.rmtree("build", ignore_errors=True)
subprocess.run(shlex.split("python3 -m build --wheel"), check=True)
wheel = f"dist/{PKG_NAME}-{version}*.whl"
for file in [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)