Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Commit 9785049

Browse files
author
Jandro
committed
Fixed bug in release.py
1 parent d74a256 commit 9785049

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

release.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212

1313

1414
DIST_PATH = 'dist'
15+
DIST_PATH_DELETE = 'dist_delete'
16+
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
1517

1618

17-
@click.group()
19+
@click.group(context_settings=CONTEXT_SETTINGS)
1820
def cli():
1921
pass
2022

2123

2224
@cli.command()
2325
def build():
26+
""" Builds the distribution files: wheels and source. """
2427
dist_path = Path(DIST_PATH)
2528
if dist_path.exists() and list(dist_path.glob('*')):
2629
if click.confirm('{} is not empty - delete contents?'.format(dist_path)):
27-
shutil.rmtree(dist_path)
30+
dist_path.rename(DIST_PATH_DELETE)
31+
shutil.rmtree(Path(DIST_PATH_DELETE))
2832
dist_path.mkdir()
2933
else:
3034
click.echo('Aborting')
@@ -38,22 +42,32 @@ def build():
3842
@cli.command()
3943
@click.option('--release/--no-release', default=False)
4044
def upload(release):
45+
""" Uploads distribuition files to pypi or pypitest. """
46+
dist_path = Path(DIST_PATH)
47+
if not dist_path.exists() or not list(dist_path.glob('*')):
48+
print("No distribution files found. Please run 'build' command first")
49+
return
50+
4151
if release:
42-
repository = 'pypi'
52+
args = ['twine', 'upload', 'dist/*']
4353
else:
44-
repository = 'pypitest'
54+
repository = 'https://test.pypi.org/legacy/'
55+
args = ['twine', 'upload', '--repository-url', repository, 'dist/*']
4556

4657
env = os.environ.copy()
4758

48-
args = ['twine', 'upload', '-r', repository, 'dist/*']
49-
5059
p = subprocess.Popen(args, env=env)
5160
p.wait()
5261

5362

5463
@cli.command()
5564
def check():
56-
""" Checks the long description """
65+
""" Checks the long description. """
66+
dist_path = Path(DIST_PATH)
67+
if not dist_path.exists() or not list(dist_path.glob('*')):
68+
print("No distribution files found. Please run 'build' command first")
69+
return
70+
5771
subprocess.check_call(['twine', 'check', 'dist/*'])
5872

5973

requirements-dev.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ requests-oauthlib==1.0.0
66
stringcase==1.2.0
77
tzlocal==1.5.1
88
Click==7.0
9-
pytest==3.9.1
9+
pytest==3.9.1
10+
twine==1.12.1
11+
wheel==0.32.1

0 commit comments

Comments
 (0)