#4 Allow bootstrapping sphinx
Merged 5 years ago by cstratak. Opened 5 years ago by churchyard.
rpms/ churchyard/python-sphinx bootstrap  into  master

file modified
+44 -12
@@ -11,6 +11,11 @@ 

  %bcond_without imagemagick_tests

  %endif

  

+ # When bootstrapping sphinx, we don't yet have sphinxcontrib-websupport

+ %bcond_without websupport

+ # Also, we don't have all the tests requirements

+ %bcond_without tests

+ 

  # Currently, python2 version is always the default: https://fedoraproject.org/wiki/Packaging:Python#Naming

  %if 1

  %global py3_default 0
@@ -67,13 +72,15 @@ 

  BuildRequires: python2-requests

  BuildRequires: python2-packaging

  BuildRequires: python2-typing

+ %if %{with websupport}

  BuildRequires: python2-sphinxcontrib-websupport

+ %endif

  BuildRequires: environment(modules)

  

  # for fixes

  BuildRequires: dos2unix

  

- # for testing

+ %if %{with tests}

  BuildRequires: python2-nose

  BuildRequires: python2-pytest

  BuildRequires: python2-pytest-cov
@@ -126,6 +133,7 @@ 

  BuildRequires: tex(polyglossia.sty)

  BuildRequires: tex(ctablestack.sty)

  BuildRequires: tex(eu1enc.def)

+ %endif

  

  %if 0%{?with_python3}

  BuildRequires: python3-devel
@@ -134,6 +142,16 @@ 

  BuildRequires: python3-docutils

  BuildRequires: python3-jinja2

  BuildRequires: python3-pygments

+ BuildRequires: python3-six

+ BuildRequires: python3-sphinx_rtd_theme

+ BuildRequires: python3-sphinx-theme-alabaster

+ BuildRequires: python3-packaging

+ BuildRequires: python3-imagesize

+ BuildRequires: python3-requests

+ %if %{with websupport}

+ BuildRequires: python3-sphinxcontrib-websupport

+ %endif

+ %if %{with tests}

  BuildRequires: python3-nose

  BuildRequires: python3-pytest

  BuildRequires: python3-pytest-cov
@@ -143,13 +161,7 @@ 

  BuildRequires: python3-html5lib

  BuildRequires: python3-whoosh

  BuildRequires: python3-snowballstemmer

- BuildRequires: python3-six

- BuildRequires: python3-sphinx_rtd_theme

- BuildRequires: python3-sphinx-theme-alabaster

- BuildRequires: python3-packaging

- BuildRequires: python3-imagesize

- BuildRequires: python3-requests

- BuildRequires: python3-sphinxcontrib-websupport

+ %endif

  %endif # with_python3

  

  
@@ -198,7 +210,9 @@ 

  Requires:      python2-requests

  Requires:      python2-packaging

  Requires:      python2-typing

+ %if %{with websupport}

  Requires:      python2-sphinxcontrib-websupport

+ %endif

  Requires: environment(modules)

  # Needed to get rid of the alternatives config installed in f24 and f25

  # versions of the package
@@ -310,8 +324,10 @@ 

  Requires:      python3-imagesize

  Requires:      python3-requests

  Requires:      python3-six

- Requires:      python3-sphinxcontrib-websupport

  Requires:      python3-packaging

+ %if %{with websupport}

+ Requires:      python3-sphinxcontrib-websupport

+ %endif

  Recommends:    graphviz

  Recommends:    ImageMagick

  Requires: environment(modules)
@@ -394,10 +410,14 @@ 

  # fix line encoding of bundled jquery.js

  dos2unix -k ./sphinx/themes/basic/static/jquery.js

  

- %if ! %{with imagemagick_tests}

+ %if %{without imagemagick_tests}

  rm tests/test_ext_imgconverter.py

  %endif

  

+ %if %{without websupport}

+ rm tests/test_websupport.py tests/test_api_translator.py

+ %endif

+ 

  %if 0%{?with_python3}

  rm -rf %{py3dir}

  cp -a . %{py3dir}
@@ -409,9 +429,16 @@ 

  %py3_build

  %endif # with_python3

  

+ export PYTHONPATH=$PWD

  pushd doc

- make html

- make man

+ %if 0%{?with_python3}

+ export SPHINXBUILD="%{__python3} ../sphinx/cmd/build.py"

+ %else

+ export SPHINXBUILD="%{__python2} ../sphinx/cmd/build.py"

+ %endif

+ 

+ make html SPHINXBUILD="$SPHINXBUILD"

+ make man SPHINXBUILD="$SPHINXBUILD"

  rm -rf _build/html/.buildinfo

  mv _build/html ..

  popd
@@ -520,10 +547,14 @@ 

    >> sphinx.lang

  

  

+ %if %{with tests}

  %check

+ export PYTHONPATH=$PWD

+ 

  # Currently, all linkcheck tests hit external websites.  Since network access

  # is disabled in koji, we have to disable these.

  rm tests/test_build_linkcheck.py

+ 

  # Igoring test_api_translator for now as it fails on Fedora.

  # The issue has been reported upstream: https://github.com/sphinx-doc/sphinx/issues/4710

  LANG=en_US.UTF-8 %{__python2} -m pytest -v --ignore=tests/test_api_translator.py
@@ -535,6 +566,7 @@ 

  LANG=en_US.UTF-8 PYTHON=python3 make test

  popd

  %endif # with_python3

+ %endif # with tests

  

  

  %files latex

1. Introduce --without websupport

Sphinx (build)requires sphinxcontrib-websupport but that (build)requires sphinx. This bcond can be used to bootstrap this.

2. Introduce --without tests

The tests bring a lot of additional dependencies that make bootstrapping harder. This allows to build without tests.

3. Build the docs with self

The documentation was built with 'python', thus importing sphinx from python2's sitelib. Sphinx was installed because of the above mentioned buildrequirement of sphinxcontrib-websupport. Now current sphinx from PWD is used, also python3 is used when available, otherwise python2. Never just python.

Trying to build with this combination:

%bcond_with websupport
%bcond_without tests

Results in test failures in mock:

setup_command = setup(pkgroot=path(u'/tmp/pytest-of-mockbuild/pytest-0/test_build_sphinx0/test-setup'), proc=<subprocess.Popen object at 0x7f7fc83a4e10>)

    def test_build_sphinx(setup_command):
        proc = setup_command.proc
        out, err = proc.communicate()
        print(out)
        print(err)
>       assert proc.returncode == 0
E       assert 1 == 0
E        +  where 1 = <subprocess.Popen object at 0x7f7fc83a4e10>.returncode

/builddir/build/BUILD/Sphinx-1.7.2/tests/test_setup_command.py:56: AssertionError
----------------------------- Captured stdout call -----------------------------

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from sphinx.setup_command import BuildDoc
ImportError: No module named sphinx.setup_command

_____________________ test_build_sphinx_multiple_builders ______________________

setup_command = setup(pkgroot=path(u'/tmp/pytest-of-mockbuild/pytest-0/test_build_sphinx_multiple_bui0/test-setup'), proc=<subprocess.Popen object at 0x7f7fb3d14690>)

    @pytest.mark.setup_command('-b', 'html,man')
    def test_build_sphinx_multiple_builders(setup_command):
        proc = setup_command.proc
        out, err = proc.communicate()
        print(out)
        print(err)
>       assert proc.returncode == 0
E       assert 1 == 0
E        +  where 1 = <subprocess.Popen object at 0x7f7fb3d14690>.returncode

/builddir/build/BUILD/Sphinx-1.7.2/tests/test_setup_command.py:65: AssertionError
----------------------------- Captured stdout call -----------------------------

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from sphinx.setup_command import BuildDoc
ImportError: No module named sphinx.setup_command

_____________________ test_build_sphinx_with_nonascii_path _____________________

setup_command = setup(pkgroot=path(u'/tmp/pytest-of-mockbuild/pytest-0/test_build_sphinx_with_nonasci0/test-setup'), proc=<subprocess.Popen object at 0x7f7fb3ed9810>)

    @pytest.mark.usefixtures('nonascii_srcdir')
    def test_build_sphinx_with_nonascii_path(setup_command):
        proc = setup_command.proc
        out, err = proc.communicate()
        print(out)
        print(err)
>       assert proc.returncode == 0
E       assert 1 == 0
E        +  where 1 = <subprocess.Popen object at 0x7f7fb3ed9810>.returncode

/builddir/build/BUILD/Sphinx-1.7.2/tests/test_setup_command.py:108: AssertionError
----------------------------- Captured stdout call -----------------------------

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from sphinx.setup_command import BuildDoc
ImportError: No module named sphinx.setup_command

_________________ test_build_sphinx_warning_return_zero_status _________________

setup_command = setup(pkgroot=path(u'/tmp/pytest-of-mockbuild/pytest-0/test_build_sphinx_warning_retu0/test-setup'), proc=<subprocess.Popen object at 0x7f7fc872d890>)

    def test_build_sphinx_warning_return_zero_status(setup_command):
        srcdir = (setup_command.pkgroot / 'doc')
        (srcdir / 'contents.txt').write_text(
            'See :ref:`unexisting-reference-label`')
        proc = setup_command.proc
        out, err = proc.communicate()
        print(out)
        print(err)
>       assert proc.returncode == 0
E       assert 1 == 0
E        +  where 1 = <subprocess.Popen object at 0x7f7fc872d890>.returncode

/builddir/build/BUILD/Sphinx-1.7.2/tests/test_setup_command.py:131: AssertionError
----------------------------- Captured stdout call -----------------------------

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from sphinx.setup_command import BuildDoc
ImportError: No module named sphinx.setup_command

=== 4 failed, 1209 passed, 7 skipped, 1 xfailed, 1 xpassed in 103.18 seconds ===
error: Bad exit status from /var/tmp/rpm-tmp.P8Zp4H (%check)

Oh, that should be juts a PYTHONPATH thing, let me check.

rebased onto dff8b44114a255fcd677c672c41f9e35d007521a

5 years ago

Ok, this fixed the problem, but more tests fail and those need to be excluded. Btw this means previously at least some tests were run against previous sphinx build.

rebased onto 56a01bbdce7315bb083dcf4884765a0a119027b8

5 years ago

rebased onto da1eff5

5 years ago

at da1eff5:

%bcond_without websupport
%bcond_without tests
https://koji.fedoraproject.org/koji/taskinfo?taskID=26967775

%bcond_with websupport
%bcond_without tests
https://koji.fedoraproject.org/koji/taskinfo?taskID=26967777

%bcond_without websupport
%bcond_with tests
https://koji.fedoraproject.org/koji/taskinfo?taskID=26967802

%bcond_with websupport
%bcond_with tests
https://koji.fedoraproject.org/koji/taskinfo?taskID=26967804

All PASS.

Pull-Request has been merged by cstratak

5 years ago