From 37a6284c9fcd71a3d4b2fe5dbc802fcf5cbe0786 Mon Sep 17 00:00:00 2001
From: Melissa Li
Date: Thu, 18 Feb 2021 23:02:29 -0500
Subject: [PATCH 1/4] Fix sphinx upload_docs
---
setup.cfg | 1 +
setuptools/command/upload_docs.py | 7 +++-
setuptools/tests/requirements.txt | 1 +
setuptools/tests/test_sphinx_upload_docs.py | 42 +++++++++++++++++++++
4 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 setuptools/tests/test_sphinx_upload_docs.py
diff --git a/setup.cfg b/setup.cfg
index e0c4edc2e6..3368d88dfa 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -58,6 +58,7 @@ testing =
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
pytest-xdist
+ sphinx
docs =
# Keep these in sync with docs/requirements.txt
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index 2559458a1d..95383319ef 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
@@ -59,7 +59,10 @@ def finalize_options(self):
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
+ for (builder, builder_dir) in build_sphinx.builder_target_dirs:
+ if builder == "html":
+ self.target_dir = builder_dir
+ break
else:
build = self.get_finalized_command('build')
self.target_dir = os.path.join(build.build_base, 'docs')
diff --git a/setuptools/tests/requirements.txt b/setuptools/tests/requirements.txt
index d0d07f70c0..b2d84a941e 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 0000000000..4287b00e4e
--- /dev/null
+++ b/setuptools/tests/test_sphinx_upload_docs.py
@@ -0,0 +1,42 @@
+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')
+@pytest.mark.usefixtures('user_override')
+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()
From df9ff438af59bc90c2f37a4180d1560d2ebca541 Mon Sep 17 00:00:00 2001
From: Melissa Li
Date: Fri, 19 Feb 2021 19:26:28 -0500
Subject: [PATCH 2/4] Add changelog
---
changelog.d/2573.change.rst | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 changelog.d/2573.change.rst
diff --git a/changelog.d/2573.change.rst b/changelog.d/2573.change.rst
new file mode 100644
index 0000000000..b06bd8c954
--- /dev/null
+++ b/changelog.d/2573.change.rst
@@ -0,0 +1,2 @@
+Fixed error in uploading a Sphinx doc with the :code:`upload_docs` command. An html builder will be used.
+Note: :code:`upload_docs` is deprecated for PyPi, but is supported for other sites -- by :user:`melissa-kun-li`
\ No newline at end of file
From 4d72bbd3906ea609cce5e5ed8b89b379ae8d65e7 Mon Sep 17 00:00:00 2001
From: Melissa Li
Date: Fri, 19 Feb 2021 20:59:24 -0500
Subject: [PATCH 3/4] Update fix and documentation
---
setuptools/command/upload_docs.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py
index 95383319ef..845bff4421 100644
--- a/setuptools/command/upload_docs.py
+++ b/setuptools/command/upload_docs.py
@@ -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,10 +59,7 @@ def finalize_options(self):
if self.upload_dir is None:
if self.has_sphinx():
build_sphinx = self.get_finalized_command('build_sphinx')
- for (builder, builder_dir) in build_sphinx.builder_target_dirs:
- if builder == "html":
- self.target_dir = builder_dir
- break
+ 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')
@@ -70,7 +67,7 @@ def finalize_options(self):
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):
From ba68d13940659709fff8035e17bef7ae7c574618 Mon Sep 17 00:00:00 2001
From: Melissa Li
Date: Fri, 19 Feb 2021 20:59:58 -0500
Subject: [PATCH 4/4] Update sphinx upload_docs test
---
setuptools/tests/test_sphinx_upload_docs.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/setuptools/tests/test_sphinx_upload_docs.py b/setuptools/tests/test_sphinx_upload_docs.py
index 4287b00e4e..a48ba7f8b3 100644
--- a/setuptools/tests/test_sphinx_upload_docs.py
+++ b/setuptools/tests/test_sphinx_upload_docs.py
@@ -25,7 +25,6 @@ def sphinx_doc_sample_project(tmpdir_cwd):
@pytest.mark.usefixtures('sphinx_doc_sample_project')
-@pytest.mark.usefixtures('user_override')
class TestSphinxUploadDocs:
def test_sphinx_doc(self):
params = dict(