OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python2.7 |
| 2 # Copyright 2015-2016, Google Inc. |
| 3 # All rights reserved. |
| 4 # |
| 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are |
| 7 # met: |
| 8 # |
| 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. |
| 11 # * Redistributions in binary form must reproduce the above |
| 12 # copyright notice, this list of conditions and the following disclaimer |
| 13 # in the documentation and/or other materials provided with the |
| 14 # distribution. |
| 15 # * Neither the name of Google Inc. nor the names of its |
| 16 # contributors may be used to endorse or promote products derived from |
| 17 # this software without specific prior written permission. |
| 18 # |
| 19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 |
| 31 import argparse |
| 32 import os |
| 33 import shutil |
| 34 import subprocess |
| 35 |
| 36 parser = argparse.ArgumentParser( |
| 37 description='Submit the package to a PyPI repository.') |
| 38 parser.add_argument( |
| 39 '--repository', '-r', metavar='r', type=str, default='pypi', |
| 40 help='The repository to push the package to. ' |
| 41 'Ensure the value appears in your .pypirc file. ' |
| 42 'Defaults to "pypi".' |
| 43 ) |
| 44 parser.add_argument( |
| 45 '--identity', '-i', metavar='i', type=str, |
| 46 help='GPG identity to sign the files with.' |
| 47 ) |
| 48 parser.add_argument( |
| 49 '--username', '-u', metavar='u', type=str, |
| 50 help='Username to authenticate with the repository. Not needed if you have ' |
| 51 'configured your .pypirc to include your username.' |
| 52 ) |
| 53 parser.add_argument( |
| 54 '--password', '-p', metavar='p', type=str, |
| 55 help='Password to authenticate with the repository. Not needed if you have ' |
| 56 'configured your .pypirc to include your password.' |
| 57 ) |
| 58 parser.add_argument( |
| 59 '--bdist', '-b', action='store_true', |
| 60 help='Generate a binary distribution (wheel) for the current OS.' |
| 61 ) |
| 62 parser.add_argument( |
| 63 '--dist-args', type=str, |
| 64 help='Additional arguments to pass to the *dist setup.py command.' |
| 65 ) |
| 66 args = parser.parse_args() |
| 67 |
| 68 # Move to the root directory of Python GRPC. |
| 69 pkgdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 70 '../../../') |
| 71 # Remove previous distributions; they somehow confuse twine. |
| 72 try: |
| 73 shutil.rmtree(os.path.join(pkgdir, 'dist/')) |
| 74 except: |
| 75 pass |
| 76 |
| 77 # Build the Cython C files |
| 78 build_env = os.environ.copy() |
| 79 build_env['GRPC_PYTHON_BUILD_WITH_CYTHON'] = "1" |
| 80 cmd = ['python', 'setup.py', 'build_ext', '--inplace'] |
| 81 subprocess.call(cmd, cwd=pkgdir, env=build_env) |
| 82 |
| 83 # Make the push. |
| 84 if args.bdist: |
| 85 cmd = ['python', 'setup.py', 'bdist_wheel'] |
| 86 else: |
| 87 cmd = ['python', 'setup.py', 'sdist'] |
| 88 if args.dist_args: |
| 89 cmd += args.dist_args.split() |
| 90 subprocess.call(cmd, cwd=pkgdir) |
| 91 |
| 92 cmd = ['twine', 'upload', '-r', args.repository] |
| 93 if args.identity is not None: |
| 94 cmd.extend(['-i', args.identity]) |
| 95 if args.username is not None: |
| 96 cmd.extend(['-u', args.username]) |
| 97 if args.password is not None: |
| 98 cmd.extend(['-p', args.password]) |
| 99 cmd.append('dist/*') |
| 100 |
| 101 subprocess.call(cmd, cwd=pkgdir) |
OLD | NEW |