-
Notifications
You must be signed in to change notification settings - Fork 34
/
build_distrib.py
37 lines (32 loc) · 1.56 KB
/
build_distrib.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
import subprocess
import argparse
import shutil
def update():
subprocess.call(["python","-m","pip","install","-U","wheel","twine"])
def clear_build():
shutil.rmtree("build",ignore_errors=True)
shutil.rmtree("dist",ignore_errors=True)
shutil.rmtree("pylablib.egg-info",ignore_errors=True)
shutil.rmtree("pylablib_lightweight.egg-info",ignore_errors=True)
def make(wheel):
subprocess.call(["python","setup.py","sdist"]+(["bdist_wheel"] if wheel else []))
def upload(production=False):
if production:
subprocess.call(["python","-m","twine","upload","--skip-existing","dist/*"])
else:
subprocess.call(["python","-m","twine","upload","--repository","testpypi","--skip-existing","dist/*"])
# pip install -U --no-cache-dir --extra-index-url https://testpypi.python.org/pypi pylablib
parser=argparse.ArgumentParser()
parser.add_argument("--update",action="store_true",help="Update wheel and twine packages before run")
parser.add_argument("-b","--build",action="store_true",help="clear the build and run setup.py")
parser.add_argument("-w","--wheel",action="store_true",help="build a wheel in addition to a pure Python distribution")
parser.add_argument("-u","--upload",action="store_true",help="upload to the server (testpy, unless -p is also specified)")
parser.add_argument("-p","--production",action="store_true",help="upload to the main pypi server (if -u is also specified)")
args=parser.parse_args()
if args.update:
update()
if args.build:
clear_build()
make(args.wheel)
if args.upload:
upload(production=args.production)