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()
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)
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)
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()
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()
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)
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)
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)