mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Add the upload command. Make all dist commands register their
outputs with the distribution object.
This commit is contained in:
		
							parent
							
								
									e6c430dffe
								
							
						
					
					
						commit
						55f1bb8bfa
					
				
					 8 changed files with 56 additions and 2 deletions
				
			
		
							
								
								
									
										35
									
								
								Doc/dist/dist.tex
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								Doc/dist/dist.tex
									
										
									
									
										vendored
									
									
								
							|  | @ -1715,7 +1715,37 @@ By default PyPI will list all versions of a given package. To hide certain | ||||||
| versions, the Hidden property should be set to yes. This must be edited | versions, the Hidden property should be set to yes. This must be edited | ||||||
| through the web interface. | through the web interface. | ||||||
| 
 | 
 | ||||||
|  | \section{The .pypirc file} | ||||||
|  | \label{pypirc} | ||||||
| 
 | 
 | ||||||
|  | The format of the \file{.pypirc} file is formated as follows: | ||||||
|  | 
 | ||||||
|  | \begin{verbatim} | ||||||
|  | [server-login] | ||||||
|  | repository: <repository-url> | ||||||
|  | username: <username> | ||||||
|  | password: <password> | ||||||
|  | \end{verbatim} | ||||||
|  | 
 | ||||||
|  | \var{repository} can be ommitted and defaults to | ||||||
|  | \code{http://www.python.org/pypi}. | ||||||
|  | 
 | ||||||
|  | \chapter{Uploading Packages to the Package Index} | ||||||
|  | \label{package-upload} | ||||||
|  | 
 | ||||||
|  | The Python Package Index (PyPI) not only stores the package info, but also  | ||||||
|  | the package data if the author of the package wishes to. The distutils | ||||||
|  | command \command{upload} pushes the distribution files to PyPI. | ||||||
|  | 
 | ||||||
|  | The command is invokes immediately after building one or more distribution | ||||||
|  | files, e.g. as | ||||||
|  | 
 | ||||||
|  | \begin{verbatim} | ||||||
|  | python setup.py sdist bdist_wininst upload | ||||||
|  | \end{verbatim} | ||||||
|  | 
 | ||||||
|  | The \command{upload} command uses the username and password stored in | ||||||
|  | in the file \file{$HOME/.pypirc}, see \ref{pypirc}. | ||||||
| 
 | 
 | ||||||
| \chapter{Examples} | \chapter{Examples} | ||||||
| \label{examples} | \label{examples} | ||||||
|  | @ -2055,6 +2085,11 @@ line option above, the command \command{bdist\_openpkg} could be | ||||||
| implemented by the class \class{distcmds.bdist_openpkg.bdist_openpkg} | implemented by the class \class{distcmds.bdist_openpkg.bdist_openpkg} | ||||||
| or \class{buildcmds.bdist_openpkg.bdist_openpkg}. | or \class{buildcmds.bdist_openpkg.bdist_openpkg}. | ||||||
| 
 | 
 | ||||||
|  | \section{Adding new distribution types} | ||||||
|  | 
 | ||||||
|  | Commands that create distributions (i.e. files in the dist directory) | ||||||
|  | need to add (command, filename) pairs to \var{self.distribution.dist_files} | ||||||
|  | so that \command{upload} can upload it to PyPI. | ||||||
| 
 | 
 | ||||||
| \chapter{Command Reference} | \chapter{Command Reference} | ||||||
| \label{reference} | \label{reference} | ||||||
|  |  | ||||||
|  | @ -117,8 +117,9 @@ def run (self): | ||||||
|                                    ensure_relative(install.install_base)) |                                    ensure_relative(install.install_base)) | ||||||
| 
 | 
 | ||||||
|         # Make the archive |         # Make the archive | ||||||
|         self.make_archive(pseudoinstall_root, |         filename = self.make_archive(pseudoinstall_root, | ||||||
|                           self.format, root_dir=archive_root) |                                      self.format, root_dir=archive_root) | ||||||
|  |         self.distribution.dist_files.append(('bdist_dumb', filename)) | ||||||
| 
 | 
 | ||||||
|         if not self.keep_temp: |         if not self.keep_temp: | ||||||
|             remove_tree(self.bdist_dir, dry_run=self.dry_run) |             remove_tree(self.bdist_dir, dry_run=self.dry_run) | ||||||
|  |  | ||||||
|  | @ -297,12 +297,14 @@ def run (self): | ||||||
| 
 | 
 | ||||||
|         # Make a source distribution and copy to SOURCES directory with |         # Make a source distribution and copy to SOURCES directory with | ||||||
|         # optional icon. |         # optional icon. | ||||||
|  |         saved_dist_files = self.distributuion.dist_files[:] | ||||||
|         sdist = self.reinitialize_command('sdist') |         sdist = self.reinitialize_command('sdist') | ||||||
|         if self.use_bzip2: |         if self.use_bzip2: | ||||||
|             sdist.formats = ['bztar'] |             sdist.formats = ['bztar'] | ||||||
|         else: |         else: | ||||||
|             sdist.formats = ['gztar'] |             sdist.formats = ['gztar'] | ||||||
|         self.run_command('sdist') |         self.run_command('sdist') | ||||||
|  |         self.distribution.dist_files = saved_dist_files | ||||||
| 
 | 
 | ||||||
|         source = sdist.get_archive_files()[0] |         source = sdist.get_archive_files()[0] | ||||||
|         source_dir = rpm_dir['SOURCES'] |         source_dir = rpm_dir['SOURCES'] | ||||||
|  | @ -355,6 +357,7 @@ def run (self): | ||||||
|                 assert len(rpms) == 1, \ |                 assert len(rpms) == 1, \ | ||||||
|                        "unexpected number of RPM files found: %s" % rpms |                        "unexpected number of RPM files found: %s" % rpms | ||||||
|                 self.move_file(rpms[0], self.dist_dir) |                 self.move_file(rpms[0], self.dist_dir) | ||||||
|  |                 self.distribution.dist_files.append(('bdist_rpm', rpms[0])) | ||||||
|                 if debuginfo: |                 if debuginfo: | ||||||
|                     self.move_file(debuginfo[0], self.dist_dir) |                     self.move_file(debuginfo[0], self.dist_dir) | ||||||
|     # run() |     # run() | ||||||
|  |  | ||||||
|  | @ -162,6 +162,8 @@ def run (self): | ||||||
|                                     root_dir=self.bdist_dir) |                                     root_dir=self.bdist_dir) | ||||||
|         # create an exe containing the zip-file |         # create an exe containing the zip-file | ||||||
|         self.create_exe(arcname, fullname, self.bitmap) |         self.create_exe(arcname, fullname, self.bitmap) | ||||||
|  |         self.distribution.dist_files.append(('bdist_wininst',  | ||||||
|  |                                              self.get_installer_filename())) | ||||||
|         # remove the zip-file again |         # remove the zip-file again | ||||||
|         log.debug("removing temporary file '%s'", arcname) |         log.debug("removing temporary file '%s'", arcname) | ||||||
|         os.remove(arcname) |         os.remove(arcname) | ||||||
|  |  | ||||||
|  | @ -449,6 +449,7 @@ def make_distribution (self): | ||||||
|         for fmt in self.formats: |         for fmt in self.formats: | ||||||
|             file = self.make_archive(base_name, fmt, base_dir=base_dir) |             file = self.make_archive(base_name, fmt, base_dir=base_dir) | ||||||
|             archive_files.append(file) |             archive_files.append(file) | ||||||
|  |             self.distribution.dist_files.append(('sdist',file)) | ||||||
| 
 | 
 | ||||||
|         self.archive_files = archive_files |         self.archive_files = archive_files | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								Lib/distutils/command/upload.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								Lib/distutils/command/upload.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | """distutils.command.upload | ||||||
|  | 
 | ||||||
|  | Implements the Distutils 'upload' subcommand (upload package to PyPI).""" | ||||||
|  | 
 | ||||||
|  | @ -177,6 +177,11 @@ def __init__ (self, attrs=None): | ||||||
|         #   command_options = { command_name : { option : (source, value) } } |         #   command_options = { command_name : { option : (source, value) } } | ||||||
|         self.command_options = {} |         self.command_options = {} | ||||||
| 
 | 
 | ||||||
|  |         # 'dist_files' is the list of (command, file) that have been created | ||||||
|  |         # by any dist commands run so far. This is filled regardless | ||||||
|  |         # of whether the run is dry or not. | ||||||
|  |         self.dist_files = [] | ||||||
|  | 
 | ||||||
|         # These options are really the business of various commands, rather |         # These options are really the business of various commands, rather | ||||||
|         # than of the Distribution itself.  We provide aliases for them in |         # than of the Distribution itself.  We provide aliases for them in | ||||||
|         # Distribution as a convenience to the developer. |         # Distribution as a convenience to the developer. | ||||||
|  |  | ||||||
|  | @ -88,6 +88,9 @@ Extension Modules | ||||||
| Library | Library | ||||||
| ------- | ------- | ||||||
| 
 | 
 | ||||||
|  | - distutils.commands.upload was added to support uploading distribution | ||||||
|  |   files to PyPI. | ||||||
|  | 
 | ||||||
| - Bug #1163325:  Decimal infinities failed to hash.  Attempting to | - Bug #1163325:  Decimal infinities failed to hash.  Attempting to | ||||||
|   hash a NaN raised an InvalidOperation instead of a TypeError. |   hash a NaN raised an InvalidOperation instead of a TypeError. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Martin v. Löwis
						Martin v. Löwis