blob: 79ebb93e573d79e9725dbf4816126b192dee4c51 [file] [log] [blame]
Masood Malekghassemi451887b2015-03-30 17:44:19 -07001#!/usr/bin/env python
2
3import argparse
4import os
5import shutil
6import subprocess
7
8parser = argparse.ArgumentParser(
9 description='Submit the package to a PyPI repository.')
10parser.add_argument(
11 '--repository', '-r', metavar='r', type=str, default='pypi',
12 help='The repository to push the package to. '
13 'Ensure the value appears in your .pypirc file. '
14 'Defaults to "pypi".'
15)
16parser.add_argument(
17 '--identity', '-i', metavar='i', type=str,
18 help='GPG identity to sign the files with.'
19)
20parser.add_argument(
21 '--username', '-u', metavar='u', type=str,
22 help='Username to authenticate with the repository. Not needed if you have '
23 'configured your .pypirc to include your username.'
24)
25parser.add_argument(
26 '--password', '-p', metavar='p', type=str,
27 help='Password to authenticate with the repository. Not needed if you have '
28 'configured your .pypirc to include your password.'
29)
30args = parser.parse_args()
31
32# Move to the root directory of Python GRPC.
33pkgdir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
34 '../../../src/python/src')
35# Remove previous distributions; they somehow confuse twine.
36try:
37 shutil.rmtree(os.path.join(pkgdir, 'dist/'))
38except:
39 pass
40
41# Make the push.
42cmd = ['python', 'setup.py', 'sdist']
Masood Malekghassemi2b34e5a2015-04-07 11:03:11 -070043subprocess.call(cmd, cwd=pkgdir)
Masood Malekghassemi451887b2015-03-30 17:44:19 -070044
45cmd = ['twine', 'upload', '-r', args.repository]
46if args.identity is not None:
47 cmd.extend(['-i', args.identity])
48if args.username is not None:
49 cmd.extend(['-u', args.username])
50if args.password is not None:
51 cmd.extend(['-p', args.password])
52cmd.append('dist/*')
53
54subprocess.call(cmd, cwd=pkgdir)