aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Tim Emiola <tbetbetbe@users.noreply.github.com>2015-04-06 16:23:10 -0700
committerGravatar Tim Emiola <tbetbetbe@users.noreply.github.com>2015-04-06 16:23:10 -0700
commite4f2f1580ded079c5e7e047376919a7909b9c49e (patch)
treee6b721bff3933191accf8dc2cb2463dc133801ce /tools
parentfdd65f325d19ae2ffd6c95f7a7a26bee84552fce (diff)
parent451887ba2c366091f0cff96d0d71752a557223c0 (diff)
Merge pull request #1154 from soltanmm/pypi
Enable PyPI package management
Diffstat (limited to 'tools')
-rwxr-xr-xtools/distrib/python/submit.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tools/distrib/python/submit.py b/tools/distrib/python/submit.py
new file mode 100755
index 0000000000..5d8a917365
--- /dev/null
+++ b/tools/distrib/python/submit.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+import argparse
+import os
+import shutil
+import subprocess
+
+parser = argparse.ArgumentParser(
+ description='Submit the package to a PyPI repository.')
+parser.add_argument(
+ '--repository', '-r', metavar='r', type=str, default='pypi',
+ help='The repository to push the package to. '
+ 'Ensure the value appears in your .pypirc file. '
+ 'Defaults to "pypi".'
+)
+parser.add_argument(
+ '--identity', '-i', metavar='i', type=str,
+ help='GPG identity to sign the files with.'
+)
+parser.add_argument(
+ '--username', '-u', metavar='u', type=str,
+ help='Username to authenticate with the repository. Not needed if you have '
+ 'configured your .pypirc to include your username.'
+)
+parser.add_argument(
+ '--password', '-p', metavar='p', type=str,
+ help='Password to authenticate with the repository. Not needed if you have '
+ 'configured your .pypirc to include your password.'
+)
+args = parser.parse_args()
+
+# Move to the root directory of Python GRPC.
+pkgdir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ '../../../src/python/src')
+# Remove previous distributions; they somehow confuse twine.
+try:
+ shutil.rmtree(os.path.join(pkgdir, 'dist/'))
+except:
+ pass
+
+# Make the push.
+cmd = ['python', 'setup.py', 'sdist']
+subprocess.call(cmd)
+
+cmd = ['twine', 'upload', '-r', args.repository]
+if args.identity is not None:
+ cmd.extend(['-i', args.identity])
+if args.username is not None:
+ cmd.extend(['-u', args.username])
+if args.password is not None:
+ cmd.extend(['-p', args.password])
+cmd.append('dist/*')
+
+subprocess.call(cmd, cwd=pkgdir)