summaryrefslogtreecommitdiff
path: root/setuptools
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2021-02-20 12:37:47 -0500
committerGitHub <noreply@github.com>2021-02-20 12:37:47 -0500
commitd31f7f0c3d72482db7c2aebbfdb2e56ab81b817b (patch)
tree236096befc24964e2c003631f35ba10fc15e086e /setuptools
parentc121d289da5d19cf6df2bf6b64ac28916a060161 (diff)
parentba68d13940659709fff8035e17bef7ae7c574618 (diff)
downloadpython-setuptools-git-d31f7f0c3d72482db7c2aebbfdb2e56ab81b817b.tar.gz
Merge pull request #2573 from melissa-kun-li/fix-sphinx-upload-docs
Fix error uploading Sphinx doc with upload_docs. Fixes #1060
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/command/upload_docs.py8
-rw-r--r--setuptools/tests/requirements.txt1
-rw-r--r--setuptools/tests/test_sphinx_upload_docs.py41
3 files changed, 46 insertions, 4 deletions
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index 2559458a..845bff44 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -2,7 +2,7 @@
"""upload_docs
Implements a Distutils 'upload_docs' subcommand (upload documentation to
-PyPI's pythonhosted.org).
+sites other than PyPi such as devpi).
"""
from base64 import standard_b64encode
@@ -31,7 +31,7 @@ class upload_docs(upload):
# supported by Warehouse (and won't be).
DEFAULT_REPOSITORY = 'https://pypi.python.org/pypi/'
- description = 'Upload documentation to PyPI'
+ description = 'Upload documentation to sites other than PyPi such as devpi'
user_options = [
('repository=', 'r',
@@ -59,7 +59,7 @@ class upload_docs(upload):
if self.upload_dir is None:
if self.has_sphinx():
build_sphinx = self.get_finalized_command('build_sphinx')
- self.target_dir = build_sphinx.builder_target_dir
+ self.target_dir = dict(build_sphinx.builder_target_dirs)['html']
else:
build = self.get_finalized_command('build')
self.target_dir = os.path.join(build.build_base, 'docs')
@@ -67,7 +67,7 @@ class upload_docs(upload):
self.ensure_dirname('upload_dir')
self.target_dir = self.upload_dir
if 'pypi.python.org' in self.repository:
- log.warn("Upload_docs command is deprecated. Use RTD instead.")
+ log.warn("Upload_docs command is deprecated for PyPi. Use RTD instead.")
self.announce('Using upload directory %s' % self.target_dir)
def create_zipfile(self, filename):
diff --git a/setuptools/tests/requirements.txt b/setuptools/tests/requirements.txt
index d0d07f70..b2d84a94 100644
--- a/setuptools/tests/requirements.txt
+++ b/setuptools/tests/requirements.txt
@@ -11,3 +11,4 @@ paver; python_version>="3.6"
futures; python_version=="2.7"
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
+sphinx
diff --git a/setuptools/tests/test_sphinx_upload_docs.py b/setuptools/tests/test_sphinx_upload_docs.py
new file mode 100644
index 00000000..a48ba7f8
--- /dev/null
+++ b/setuptools/tests/test_sphinx_upload_docs.py
@@ -0,0 +1,41 @@
+import pytest
+import os
+
+from setuptools.command.upload_docs import upload_docs
+from setuptools.dist import Distribution
+
+
+@pytest.fixture
+def sphinx_doc_sample_project(tmpdir_cwd):
+ # setup.py
+ with open('setup.py', 'wt') as f:
+ f.write('from setuptools import setup; setup()\n')
+
+ os.makedirs('build/docs')
+
+ # A test conf.py for Sphinx
+ with open('build/docs/conf.py', 'w') as f:
+ f.write("project = 'test'")
+
+ # A test index.rst for Sphinx
+ with open('build/docs/index.rst', 'w') as f:
+ f.write(".. toctree::\
+ :maxdepth: 2\
+ :caption: Contents:")
+
+
+@pytest.mark.usefixtures('sphinx_doc_sample_project')
+class TestSphinxUploadDocs:
+ def test_sphinx_doc(self):
+ params = dict(
+ name='foo',
+ packages=['test'],
+ )
+ dist = Distribution(params)
+
+ cmd = upload_docs(dist)
+
+ cmd.initialize_options()
+ assert cmd.upload_dir is None
+ assert cmd.has_sphinx() is True
+ cmd.finalize_options()