[Python-checkins] distutils2: added upload_docs option to upload command
tarek.ziade
python-checkins at python.org
Sun Aug 8 11:50:46 CEST 2010
tarek.ziade pushed 853e5b093ab8 to distutils2:
http://hg.python.org/distutils2/rev/853e5b093ab8
changeset: 437:853e5b093ab8
parent: 382:733c3bdaa25e
user: Konrad Delong <konryd at gmail.com>
date: Thu Jul 22 19:31:26 2010 +0200
summary: added upload_docs option to upload command
files: docs/source/commands.rst, docs/source/index.rst, docs/source/new_commands.rst, src/distutils2/command/upload.py, src/distutils2/tests/test_upload.py
diff --git a/docs/source/new_commands.rst b/docs/source/commands.rst
rename from docs/source/new_commands.rst
rename to docs/source/commands.rst
--- a/docs/source/new_commands.rst
+++ b/docs/source/commands.rst
@@ -6,6 +6,50 @@
You might recognize some of them from other projects, like Distribute or
Setuptools.
+``upload`` - Upload source and/or binary distributions to PyPI
+==============================================================
+
+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 invoked immediately after building one or more distribution
+files. For example, the command ::
+
+ python setup.py sdist bdist_wininst upload
+
+will cause the source distribution and the Windows installer to be uploaded to
+PyPI. Note that these will be uploaded even if they are built using an earlier
+invocation of :file:`setup.py`, but that only distributions named on the command
+line for the invocation including the :command:`upload` command are uploaded.
+
+The :command:`upload` command uses the username, password, and repository URL
+from the :file:`$HOME/.pypirc` file . If a :command:`register` command was
+previously called in the same command, and if the password was entered in the
+prompt, :command:`upload` will reuse the entered password. This is useful if
+you do not want to store a clear text password in the :file:`$HOME/.pypirc`
+file.
+
+The ``upload`` command has a few options worth noting:
+
+``--sign, -s``
+ Sign each uploaded file using GPG (GNU Privacy Guard). The ``gpg`` program
+ must be available for execution on the system ``PATH``.
+
+``--identity=NAME, -i NAME``
+ Specify the identity or key name for GPG to use when signing. The value of
+ this option will be passed through the ``--local-user`` option of the
+ ``gpg`` program.
+
+``--show-response``
+ Display the full response text from server; this is useful for debugging
+ PyPI problems.
+
+``--repository=URL, -r URL``
+ The URL of the repository to upload to. Defaults to
+ http://pypi.python.org/pypi (i.e., the main PyPI installation).
+
+
``upload_docs`` - Upload package documentation to PyPI
======================================================
diff --git a/docs/source/index.rst b/docs/source/index.rst
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -14,7 +14,7 @@
metadata
pkgutil
depgraph
- new_commands
+ commands
test_framework
pypi
version
diff --git a/src/distutils2/command/upload.py b/src/distutils2/command/upload.py
--- a/src/distutils2/command/upload.py
+++ b/src/distutils2/command/upload.py
@@ -26,6 +26,7 @@
('sign', 's',
'sign files to upload using gpg'),
('identity=', 'i', 'GPG identity used to sign files'),
+ ('upload-docs', None, 'Run upload_docs as well'),
]
boolean_options = PyPIRCCommand.boolean_options + ['sign']
@@ -37,6 +38,7 @@
self.show_response = 0
self.sign = False
self.identity = None
+ self.upload_docs = False
def finalize_options(self):
PyPIRCCommand.finalize_options(self)
@@ -61,6 +63,12 @@
raise DistutilsOptionError("No dist file created in earlier command")
for command, pyversion, filename in self.distribution.dist_files:
self.upload_file(command, pyversion, filename)
+ if self.upload_docs:
+ upload_docs = self.get_finalized_command("upload_docs")
+ upload_docs.repository = self.repository
+ upload_docs.username = self.username
+ upload_docs.password = self.password
+ upload_docs.run()
# XXX to be refactored with register.post_to_server
def upload_file(self, command, pyversion, filename):
diff --git a/src/distutils2/tests/test_upload.py b/src/distutils2/tests/test_upload.py
--- a/src/distutils2/tests/test_upload.py
+++ b/src/distutils2/tests/test_upload.py
@@ -76,6 +76,38 @@
self.assertEqual(handler.command, 'POST')
self.assertNotIn('\n', headers['authorization'])
+ def test_upload_docs(self):
+ path = os.path.join(self.tmp_dir, 'xxx')
+ self.write_file(path)
+ command, pyversion, filename = 'xxx', '2.6', path
+ dist_files = [(command, pyversion, filename)]
+ docs_path = os.path.join(self.tmp_dir, "build", "docs")
+ os.makedirs(docs_path)
+ self.write_file(os.path.join(docs_path, "index.html"), "yellow")
+ self.write_file(self.rc, PYPIRC)
+
+ # lets run it
+ pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
+
+ cmd = upload(dist)
+ cmd.get_finalized_command("build").run()
+ cmd.upload_docs = True
+ cmd.ensure_finalized()
+ cmd.repository = self.pypi.full_address
+ try:
+ prev_dir = os.getcwd()
+ os.chdir(self.tmp_dir)
+ cmd.run()
+ finally:
+ os.chdir(prev_dir)
+
+ handler, request_data = self.pypi.requests[-1]
+ action, name, content =\
+ request_data.split("----------------GHSKFJDLGDS7543FJKLFHRE75642756743254")[1:4]
+
+ self.assertIn('name=":action"', action)
+ self.assertIn("doc_upload", action)
+
def test_suite():
return unittest.makeSuite(UploadTestCase)
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list