-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
43 lines (31 loc) · 1002 Bytes
/
tasks.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
38
39
40
41
42
43
import pathlib
import shlex
import shutil
import invoke
ROOT = pathlib.Path(__file__).resolve().parent
@invoke.task()
def build(ctx):
"""Build the package into distributables.
This will create two distributables: source and wheel.
"""
ctx.run(f'python setup.py sdist bdist_wheel')
@invoke.task()
def clean(ctx):
"""Clean previously built package artifacts.
"""
ctx.run(f'python setup.py clean')
dist = ROOT.joinpath('dist')
print(f'removing {dist}')
shutil.rmtree(str(dist))
@invoke.task(pre=[clean, build])
def upload(ctx, repo):
"""Upload the package to an index server.
This implies cleaning and re-building the package.
:param repo: Required. Name of the index server to upload to, as specifies
in your .pypirc configuration file.
"""
artifacts = ' '.join(
shlex.quote(str(n))
for n in ROOT.joinpath('dist').glob('pipfile[-_]cli-*')
)
ctx.run(f'twine upload --repository="{repo}" {artifacts}')