[Python-checkins] distutils2: Merge from Konrad, with small fixes
tarek.ziade
python-checkins at python.org
Sun Aug 8 11:50:46 CEST 2010
tarek.ziade pushed 5778145a172f to distutils2:
http://hg.python.org/distutils2/rev/5778145a172f
changeset: 438:5778145a172f
parent: 436:70cc02f1c720
parent: 437:853e5b093ab8
user: ?ric Araujo <merwok at netwok.org>
date: Wed Aug 04 15:08:39 2010 +0200
summary: Merge from Konrad, with small fixes
files: docs/source/commands.rst, docs/source/new_commands.rst, src/distutils2/command/upload.py, src/distutils2/command/upload_docs.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
======================================================
@@ -40,7 +84,7 @@
python setup.py upload_docs --upload-dir=docs/build/html
-As with any other ``setuptools`` based command, you can define useful
+As with any other command, you can define useful
defaults in the ``setup.cfg`` of your Python project, e.g.:
.. code-block:: ini
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
@@ -35,6 +35,8 @@
"sign files to upload using gpg"),
('identity=', 'i',
"GPG identity used to sign files"),
+ ('upload-docs', None,
+ "upload documentation too"),
]
boolean_options = ['show-response', 'sign']
@@ -48,6 +50,7 @@
self.show_response = 0
self.sign = False
self.identity = None
+ self.upload_docs = False
def finalize_options(self):
if self.repository is None:
@@ -75,6 +78,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/command/upload_docs.py b/src/distutils2/command/upload_docs.py
--- a/src/distutils2/command/upload_docs.py
+++ b/src/distutils2/command/upload_docs.py
@@ -64,7 +64,7 @@
self.repository = None
self.realm = None
self.show_response = 0
- self.upload_dir = "build/docs"
+ self.upload_dir = None
self.username = ''
self.password = ''
@@ -73,7 +73,7 @@
self.repository = DEFAULT_REPOSITORY
if self.realm is None:
self.realm = DEFAULT_REALM
- if self.upload_dir == None:
+ if self.upload_dir is None:
build = self.get_finalized_command('build')
self.upload_dir = os.path.join(build.build_base, "docs")
self.announce('Using upload directory %s' % self.upload_dir)
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
@@ -101,6 +101,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