lib-not-dr/scripts/pub.py

39 lines
772 B
Python
Raw Normal View History

2023-12-10 02:46:53 +08:00
import sys
import subprocess
from typing import Union
from pathlib import Path
def clean(dir_path: Union[str, Path]):
"""
clean everything in dir
will not remove dir
"""
print(f"Cleaning {dir_path}")
path_dir = Path(dir_path) if isinstance(dir_path, str) else dir_path
for path in path_dir.rglob("*"):
if path.is_file():
path.unlink()
elif path.is_dir():
clean(path)
path.rmdir()
def clean_build():
clean("./dist")
clean("./build")
def upload_gitea():
twine_cmd = [
sys.executable,
'-m', 'twine',
'upload',
'--repository',
'gitea',
'./dist/*',
'--verbose'
]
subprocess.run(twine_cmd, shell=False, check=True)