示例#1
0
 def get_setup_py_name(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted name, like
         # UserWarnings.
         utils.execute_command(utils.setup_py('egg_info'))
         return utils.execute_command(utils.setup_py('--name')).strip()
示例#2
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.error(
                "You must have a properly configured %s file in "
                "your home dir to upload to a Python package index.",
                pypi.DIST_CONFIG_FILE)
            if utils.ask("Do you want to continue without uploading?",
                         default=False):
                return
            sys.exit(1)

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get list of all files to upload.
        files_in_dist = [
            os.path.join('dist', filename) for filename in os.listdir('dist')
        ]

        # Get servers/repositories.
        servers = self.pypiconfig.distutils_servers()

        register = self.pypiconfig.register_package()
        for server in servers:
            if register:
                question = "Register and upload"
            else:
                question = "Upload"
            default = True
            exact = False
            if server == 'pypi' and not package_in_pypi(package):
                logger.info("This package is NOT registered on PyPI.")
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("%s to %s" % (question, server),
                         default=default,
                         exact=exact):
                if register:
                    logger.info("Registering...")
                    # We only need the first file, it has all the needed info
                    self._retry_twine('register', server, files_in_dist[0])
                for filename in files_in_dist:
                    self._retry_twine('upload', server, filename)
        self._close_all_repositories()
示例#3
0
文件: vcs.py 项目: keul/zest.releaser
 def get_setup_py_name(self):
     if os.path.exists("setup.py"):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted name, like
         # UserWarnings.
         system(utils.setup_py("egg_info"))
         return system(utils.setup_py("--name")).strip()
示例#4
0
 def get_setup_py_name(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted name, like
         # UserWarnings.
         system(utils.setup_py('egg_info'))
         return system(utils.setup_py('--name')).strip()
示例#5
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.error(
                "You must have a properly configured %s file in "
                "your home dir to upload to a Python package index.",
                pypi.DIST_CONFIG_FILE)
            if utils.ask("Do you want to continue without uploading?",
                         default=False):
                return
            sys.exit(1)

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get list of all files to upload.
        files_in_dist = sorted([
            os.path.join('dist', filename) for filename in os.listdir('dist')
        ])

        register = self.pypiconfig.register_package()

        # If TWINE_REPOSITORY_URL is set, use it.
        if self.pypiconfig.twine_repository_url():
            if not self._ask_upload(
                    package, self.pypiconfig.twine_repository_url(), register):
                return

            if register:
                self._retry_twine("register", None, files_in_dist[:1])

            self._retry_twine("upload", None, files_in_dist)
            # Only upload to the server specified in the environment
            return

        # Upload to the repository in the environment or .pypirc
        servers = self.pypiconfig.distutils_servers()

        for server in servers:
            if not self._ask_upload(package, server, register):
                continue

            if register:
                logger.info("Registering...")
                # We only need the first file, it has all the needed info
                self._retry_twine('register', server, files_in_dist[:1])
            self._retry_twine('upload', server, files_in_dist)
示例#6
0
    def _upload_distributions(self, package, sdist_options, pypiconfig):
        # See if creating an egg actually works.
        logger.info("Making an egg of a fresh tag checkout.")
        print system(utils.setup_py('sdist ' + sdist_options))

        # First ask if we want to upload to pypi, which should always
        # work, also without collective.dist.
        use_pypi = package_in_pypi(package)
        if use_pypi:
            logger.info("This package is registered on PyPI.")
        else:
            logger.warn("This package is NOT registered on PyPI.")
        if pypiconfig.is_old_pypi_config():
            pypi_command = 'register sdist %s upload' % sdist_options
            shell_command = utils.setup_py(pypi_command)
            if use_pypi:
                default = True
                exact = False
            else:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to PyPI", default=default,
                         exact=exact):
                logger.info("Running: %s", shell_command)
                result = system(shell_command)
                utils.show_first_and_last_lines(result)

        # If collective.dist is installed (or we are using
        # python2.6 or higher), the user may have defined
        # other servers to upload to.
        for server in pypiconfig.distutils_servers():
            if pypi.new_distutils_available():
                commands = ('register', '-r', server, 'sdist',
                            sdist_options, 'upload', '-r', server)
            else:
                ## This would be logical, given the lines above:
                #commands = ('mregister', '-r', server, 'sdist',
                #            sdist_options, 'mupload', '-r', server)
                ## But according to the collective.dist documentation
                ## it should be this (with just one '-r'):
                commands = ('mregister', 'sdist',
                            sdist_options, 'mupload', '-r', server)
            shell_command = utils.setup_py(' '.join(commands))
            default = True
            exact = False
            if server == 'pypi' and not use_pypi:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to %s" % server,
                         default=default, exact=exact):
                logger.info("Running: %s", shell_command)
                result = system(shell_command)
                utils.show_first_and_last_lines(result)
示例#7
0
 def get_setup_py_version(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         system(utils.setup_py('egg_info'))
         version = system(utils.setup_py('--version'))
         return utils.strip_version(version)
示例#8
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.error(
                "You must have a properly configured %s file in "
                "your home dir to upload to a Python package index.",
                pypi.DIST_CONFIG_FILE)
            if utils.ask("Do you want to continue without uploading?",
                         default=False):
                return
            sys.exit(1)

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get list of all files to upload.
        files_in_dist = sorted([
            os.path.join('dist', filename) for filename in os.listdir('dist')]
        )

        # Get servers/repositories.
        servers = self.pypiconfig.distutils_servers()

        register = self.pypiconfig.register_package()
        for server in servers:
            default = True
            exact = False
            if server == 'pypi' and not package_in_pypi(package):
                logger.info("This package does NOT exist yet on PyPI.")
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            question = "Upload"
            if register:
                question = "Register and upload"
            if utils.ask("%s to %s" % (question, server),
                         default=default, exact=exact):
                if register:
                    logger.info("Registering...")
                    # We only need the first file, it has all the needed info
                    self._retry_twine('register', server, files_in_dist[:1])
                self._retry_twine('upload', server, files_in_dist)
示例#9
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.warn(
                "You must have a properly configured %s file in "
                "your home dir to upload to a package index.",
                pypi.DIST_CONFIG_FILE)
            return

        # Get list of all files to upload.
        files_in_dist = [
            os.path.join('dist', filename) for filename in os.listdir('dist')
        ]

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get servers/repositories.
        if self.pypiconfig.is_old_pypi_config():
            servers = ['pypi']
        else:
            # The user may have defined other servers to upload to.
            servers = self.pypiconfig.distutils_servers()

        for server in servers:
            if self.pypiconfig.register_package():
                logger.info("Registering...")
                # We only need the first file, it has all the needed info
                self._retry_twine('register', server, files_in_dist[0])
            question = "Upload"
            default = True
            exact = False
            if utils.ask("%s to %s" % (question, server),
                         default=default,
                         exact=exact):
                for filename in files_in_dist:
                    self._retry_twine('upload', server, filename)
        self._close_all_repositories()
示例#10
0
 def get_setup_py_version(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         system(utils.setup_py('egg_info'))
         version = system(utils.setup_py('--version')).splitlines()[0]
         if version.startswith('Traceback'):
             # Likely cause is for example forgetting to 'import
             # os' when using 'os' in setup.py.
             logger.critical('The setup.py of this package has an error:')
             print version
             logger.critical('No version found.')
             sys.exit(1)
         return utils.strip_version(version)
示例#11
0
 def get_setup_py_version(self):
     if os.path.exists('setup.py'):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         system(utils.setup_py('egg_info'))
         version = system(utils.setup_py('--version')).splitlines()[0]
         if version.startswith('Traceback'):
             # Likely cause is for example forgetting to 'import
             # os' when using 'os' in setup.py.
             logger.critical('The setup.py of this package has an error:')
             print version
             logger.critical('No version found.')
             sys.exit(1)
         return utils.strip_version(version)
示例#12
0
文件: vcs.py 项目: keul/zest.releaser
 def get_setup_py_version(self):
     if os.path.exists("setup.py"):
         # First run egg_info, as that may get rid of some warnings
         # that otherwise end up in the extracted version, like
         # UserWarnings.
         system(utils.setup_py("egg_info"))
         version = system(utils.setup_py("--version"))
         if version.startswith("Traceback"):
             # Likely cause is for example forgetting to 'import
             # os' when using 'os' in setup.py.
             logger.critical("The setup.py of this package has an error:")
             print version
             logger.critical("No version found.")
             sys.exit(1)
         return utils.strip_version(version)
示例#13
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)"
        )
        sys.exit(1)

    filename = tempfile.mktemp(".html")
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py("--long-description"))
    warnings = io.StringIO()
    html = render(longdesc, warnings)
    if html is None:
        logging.error("Error generating html. Invalid ReST.")
        rst_filename = tempfile.mktemp(".rst")
        with open(rst_filename, "wb") as rst_file:
            rst_file.write(longdesc.encode("utf-8"))
        warning_text = warnings.getvalue()
        warning_text = warning_text.replace("<string>", rst_filename)
        print(warning_text)
        sys.exit(1)

    if "<html" not in html[:20]:
        # Add a html declaration including utf-8 indicator
        html = HTML_PREFIX + html + HTML_POSTFIX

    with open(filename, "wb") as fh:
        fh.write(html.encode("utf-8"))

    url = "file://" + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#14
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html = render(longdesc, warnings)
    if html is None:
        logging.error('Error generating html. Invalid ReST.')
        rst_filename = tempfile.mktemp('.rst')
        with open(rst_filename, 'wb') as rst_file:
            rst_file.write(longdesc.encode('utf-8'))
        warning_text = warnings.getvalue()
        warning_text = warning_text.replace('<string>', rst_filename)
        print(warning_text)
        sys.exit(1)

    if not '<html' in html[:20]:
        # Add a html declaration including utf-8 indicator
        html = HTML_PREFIX + html + HTML_POSTFIX

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#15
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html, rendered = render(longdesc, warnings)
    if not rendered:
        logging.error(
            'Error generating html. Invalid ReST.')
        print(warnings.getvalue())
        sys.exit(1)

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
def upload(context):
    ''' Upload sphinx doc'''
    config = ConfigParser.ConfigParser()
    config.read(os.path.join(context['workingdir'], 'setup.cfg'))
    if SECTION not in config.sections():
        return None
    
    build_command = 'build_sphinx'
    upload_command = 'upload_sphinx'
    if not zest.releaser.utils.ask('Upload documentation to http://packages.python.org'):
        return
    # build documentation
    shell_command = utils.setup_py(build_command)
    result = zest.releaser.utils.system(shell_command)
    
    # upload documentation
    shell_command = utils.setup_py(upload_command)
    result = zest.releaser.utils.system(shell_command)
示例#17
0
def show_longdesc():
    filename1 = tempfile.mktemp()
    filename2 = tempfile.mktemp()
    filename2 = filename2 + '.html'
    error = os.system(utils.setup_py('--long-description > %s' % filename1))
    if error:
        logging.error('Error generating long description.')
        sys.exit()
    error = os.system('rst2html.py %s > %s' % (filename1, filename2))
    if error:
        # On Linux it needs to be 'rst2html', without the '.py'
        error = os.system('rst2html %s > %s' % (filename1, filename2))
    if error:
        # Alternatively, zc.rst2 provides rst2 xyz.
        error = os.system('rst2 html %s > %s' % (filename1, filename2))
    if error:
        logging.error(
            'Error generating html. Please install docutils (or zc.rst2).')
        sys.exit()
    url = 'file://' + filename2
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#18
0
def show_longdesc():
    filename1 = tempfile.mktemp()
    filename2 = tempfile.mktemp()
    filename2 = filename2 + '.html'
    error = os.system(utils.setup_py('--long-description > %s' %
                                     filename1))
    if error:
        logging.error('Error generating long description.')
        sys.exit()
    error = os.system('rst2html.py %s > %s' % (filename1, filename2))
    if error:
        # On Linux it needs to be 'rst2html', without the '.py'
        error = os.system('rst2html %s > %s' % (filename1, filename2))
    if error:
        # Alternatively, zc.rst2 provides rst2 xyz.
        error = os.system('rst2 html %s > %s' % (filename1, filename2))
    if error:
        logging.error(
            'Error generating html. Please install docutils (or zc.rst2).')
        sys.exit()
    url = 'file://' + filename2
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#19
0
def show_longdesc():
    if not HAVE_README:
        logging.error(
            "To check the long description, we need the 'readme' package. "
            "(It is included if you install `zest.releaser[recommended]`)")
        sys.exit(1)

    filename = tempfile.mktemp('.html')
    # Note: for the setup.py call we use _execute_command() from our
    # utils module. This makes sure the python path is set up right.
    longdesc = _execute_command(utils.setup_py('--long-description'))
    warnings = io.StringIO()
    html, rendered = render(longdesc, warnings)
    if not rendered:
        logging.error('Error generating html. Invalid ReST.')
        print(warnings.getvalue())
        sys.exit(1)

    with open(filename, 'wb') as fh:
        fh.write(html.encode('utf-8'))

    url = 'file://' + filename
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#20
0
def show_longdesc():
    filename1 = tempfile.mktemp()
    filename2 = tempfile.mktemp()
    filename2 = filename2 + '.html'
    # Note: for the setup.py call we use system() from our utils module. This
    # makes sure the python path is set up right.
    # For the other calls we use os.system(), because that returns an error
    # code which we need.
    system(utils.setup_py('--long-description > %s' %
                          filename1))
    error = os.system('rst2html.py %s > %s' % (filename1, filename2))
    if error:
        # On Linux it needs to be 'rst2html', without the '.py'
        error = os.system('rst2html %s > %s' % (filename1, filename2))
    if error:
        # Alternatively, zc.rst2 provides rst2 xyz.
        error = os.system('rst2 html %s > %s' % (filename1, filename2))
    if error:
        logging.error(
            'Error generating html. Please install docutils (or zc.rst2).')
        sys.exit()
    url = 'file://' + filename2
    logging.info("Opening %s in your webbrowser.", url)
    webbrowser.open(url)
示例#21
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.warn("You must have a properly configured %s file in "
                        "your home dir to upload to a package index.",
                        pypi.DIST_CONFIG_FILE)
            return

        # Get list of all files to upload.
        files_in_dist = [
            os.path.join('dist', filename) for filename in os.listdir('dist')]

        # Is this package already registered on pypi?
        on_pypi = package_in_pypi(package)

        # Run extra entry point
        self._run_hooks('before_upload')

        # Get servers/repositories.
        if self.pypiconfig.is_old_pypi_config():
            servers = ['pypi']
        else:
            # The user may have defined other servers to upload to.
            servers = self.pypiconfig.distutils_servers()

        for server in servers:
            if server == 'pypi' and on_pypi:
                logger.info("This package is registered on PyPI.")
                # Already registered on PyPI.  Uploading is enough.
                do_register = False
                question = "Upload"
            else:
                # We must register first.
                do_register = True
                question = "Register and upload"
            default = True
            exact = False
            if server == 'pypi' and not on_pypi:
                logger.info("This package is NOT registered on PyPI.")
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("%s to %s" % (question, server),
                         default=default, exact=exact):
                if do_register:
                    logger.info("Registering...")
                    utils.retry_twine('register', server, *files_in_dist)
                utils.retry_twine('upload', server, *files_in_dist)
示例#22
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info("Making a source distribution of a fresh tag checkout (in %s).", self.data["tagworkingdir"])
        result = utils.execute_command(utils.setup_py("sdist"))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).", self.data["tagworkingdir"])
            result = utils.execute_command(utils.setup_py("bdist_wheel"))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.warn(
                "You must have a properly configured %s file in " "your home dir to upload to a package index.",
                pypi.DIST_CONFIG_FILE,
            )
            return

        # Is this package already registered on pypi?
        on_pypi = package_in_pypi(package)

        # Run extra entry point
        self._run_hooks("before_upload")

        # Get list of all files to upload.
        files_in_dist = [os.path.join("dist", filename) for filename in os.listdir("dist")]

        # Get servers/repositories.
        if self.pypiconfig.is_old_pypi_config():
            servers = ["pypi"]
        else:
            # The user may have defined other servers to upload to.
            servers = self.pypiconfig.distutils_servers()

        for server in servers:
            if server == "pypi" and on_pypi:
                logger.info("This package is registered on PyPI.")
                # Already registered on PyPI.  Uploading is enough.
                do_register = False
                question = "Upload"
            else:
                # We must register first.
                do_register = True
                question = "Register and upload"
            default = True
            exact = False
            if server == "pypi" and not on_pypi:
                logger.info("This package is NOT registered on PyPI.")
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("%s to %s" % (question, server), default=default, exact=exact):
                if do_register:
                    logger.info("Registering...")
                    # We only need to first file, it has all the needed info.
                    self._retry_twine("register", server, files_in_dist[0])
                for filename in files_in_dist:
                    self._retry_twine("upload", server, filename)
        self._close_all_repositories()
示例#23
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.warn(
                "You must have a properly configured %s file in "
                "your home dir to upload to a package index.",
                pypi.DIST_CONFIG_FILE)
            return

        # If twine is available, we prefer it for uploading.  But:
        # currently, when a package is not yet registered, twine
        # upload will fail.
        use_twine = utils.has_twine()

        # First ask if we want to upload to pypi.
        use_pypi = package_in_pypi(package)
        if use_pypi:
            logger.info("This package is registered on PyPI.")
        else:
            logger.warn("This package is NOT registered on PyPI.")
            if use_twine:
                logger.warn("Please login and manually register this "
                            "package on PyPI first.")

        # Run extra entry point
        self._run_hooks('before_upload')

        if self.pypiconfig.is_old_pypi_config():
            if use_twine:
                shell_command = utils.twine_command('upload dist%s*' %
                                                    os.path.sep)
            else:
                if self.pypiconfig.create_wheel():
                    pypi_command = 'register sdist bdist_wheel upload'
                else:
                    pypi_command = 'register sdist upload'
                shell_command = utils.setup_py(pypi_command)
            if use_pypi:
                default = True
                exact = False
            else:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to PyPI",
                         default=default,
                         exact=exact):
                logger.info("Running: %s", shell_command)
                self._pypi_command(shell_command)

        # The user may have defined other servers to upload to.
        for server in self.pypiconfig.distutils_servers():
            if use_twine:
                shell_command = utils.twine_command('upload dist%s* -r %s' %
                                                    (os.path.sep, server))
            else:
                if self.pypiconfig.create_wheel():
                    commands = ('register', '-r', server, 'sdist',
                                'bdist_wheel', 'upload', '-r', server)
                else:
                    commands = ('register', '-r', server, 'sdist', 'upload',
                                '-r', server)
                shell_command = utils.setup_py(' '.join(commands))
            default = True
            exact = False
            if server == 'pypi' and not use_pypi:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to %s" % server,
                         default=default,
                         exact=exact):
                logger.info("Running: %s", shell_command)
                self._pypi_command(shell_command)
示例#24
0
    def _upload_distributions(self, package):
        # See if creating an sdist (and maybe a wheel) actually works.
        # Also, this makes the sdist (and wheel) available for plugins.
        # And for twine, who will just upload the created files.
        logger.info(
            "Making a source distribution of a fresh tag checkout (in %s).",
            self.data['tagworkingdir'])
        result = utils.execute_command(utils.setup_py('sdist'))
        utils.show_interesting_lines(result)
        if self.pypiconfig.create_wheel():
            logger.info("Making a wheel of a fresh tag checkout (in %s).",
                        self.data['tagworkingdir'])
            result = utils.execute_command(utils.setup_py('bdist_wheel'))
        utils.show_interesting_lines(result)
        if not self.pypiconfig.is_pypi_configured():
            logger.warn("You must have a properly configured %s file in "
                        "your home dir to upload to a package index.",
                        pypi.DIST_CONFIG_FILE)
            return

        # If twine is available, we prefer it for uploading.  But:
        # currently, when a package is not yet registered, twine
        # upload will fail.
        use_twine = utils.has_twine()

        # First ask if we want to upload to pypi.
        use_pypi = package_in_pypi(package)
        if use_pypi:
            logger.info("This package is registered on PyPI.")
        else:
            logger.warn("This package is NOT registered on PyPI.")
            if use_twine:
                logger.warn("Please login and manually register this "
                            "package on PyPI first.")

        # Run extra entry point
        self._run_hooks('before_upload')

        if self.pypiconfig.is_old_pypi_config():
            if use_twine:
                shell_command = utils.twine_command(
                    'upload dist%s*' % os.path.sep)
            else:
                if self.pypiconfig.create_wheel():
                    pypi_command = 'register sdist bdist_wheel upload'
                else:
                    pypi_command = 'register sdist upload'
                shell_command = utils.setup_py(pypi_command)
            if use_pypi:
                default = True
                exact = False
            else:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to PyPI", default=default,
                         exact=exact):
                logger.info("Running: %s", shell_command)
                self._pypi_command(shell_command)

        # The user may have defined other servers to upload to.
        for server in self.pypiconfig.distutils_servers():
            if use_twine:
                shell_command = utils.twine_command('upload dist%s* -r %s' % (
                    os.path.sep, server))
            else:
                if self.pypiconfig.create_wheel():
                    commands = ('register', '-r', server, 'sdist',
                                'bdist_wheel',
                                'upload', '-r', server)
                else:
                    commands = ('register', '-r', server, 'sdist',
                                'upload', '-r', server)
                shell_command = utils.setup_py(' '.join(commands))
            default = True
            exact = False
            if server == 'pypi' and not use_pypi:
                # We are not yet on pypi.  To avoid an 'Oops...,
                # sorry!' when registering and uploading an internal
                # package we default to False here.
                default = False
                exact = True
            if utils.ask("Register and upload to %s" % server,
                         default=default, exact=exact):
                logger.info("Running: %s", shell_command)
                self._pypi_command(shell_command)