Only build scipy once (per Python)

The build_sphinx setup.py command previously used to build the docs
calls build_ext --inplace internally. That's one build.

Later the install command was called and that calls build as well.
Inplace and non-inplace builds happen separately.

By first explicitly building with build and then invoking sphinx
trough the Makefile, we can use install --skip-build (%pyX_install).

Explicit call to sphinx also removes the need to remove conf.py
from bundled projects.

This also saves us setting the build flags in %install, which was
previously only needed because of the build happening there.

While doing this, I've also switched the build section to build for
for Python 3 and Python 2 in a loop to make the specfile DRY.
This commit is contained in:
Miro Hrončok 2018-06-23 10:10:51 +02:00
parent c1994df3a0
commit 33f8ec88d1

View File

@ -129,73 +129,37 @@ openblas_libs = openblasp
%endif %endif
EOF EOF
# sphinx_build somehow randomly decides which docs to build here # remove bundled numpydoc
# there is: doc/source/conf.py - scipy docs - we want that one rm doc/sphinxext -r
# doc/sphinxext/doc/conf.py - bundled numpydoc documentation
# doc/scipy-sphinx-theme/conf.py - testing documentation for the theme
rm doc/sphinxext -r # contains only bundled numpydoc
rm doc/scipy-sphinx-theme/conf.py
%build %build
env CFLAGS="$RPM_OPT_FLAGS -lm" \ for PY in %{python3_version} %{python2_version}; do
env CFLAGS="$RPM_OPT_FLAGS -lm" \
FFLAGS="$RPM_OPT_FLAGS -fPIC" \ FFLAGS="$RPM_OPT_FLAGS -fPIC" \
%ifarch %{openblas_arches} %ifarch %{openblas_arches}
OPENBLAS=%{_libdir} \ OPENBLAS=%{_libdir} \
%else %else
ATLAS=%{_libdir}/atlas \ ATLAS=%{_libdir}/atlas \
%endif %endif
FFTW=%{_libdir} BLAS=%{_libdir} LAPACK=%{_libdir} \ FFTW=%{_libdir} BLAS=%{_libdir} LAPACK=%{_libdir} \
%__python3 setup.py config_fc \ %{_bindir}/python$PY setup.py config_fc \
--fcompiler=gnu95 --noarch \ --fcompiler=gnu95 --noarch \
%if %{with doc}
build_sphinx
rm -r build/sphinx/html/.buildinfo
mv build/sphinx build/sphinx-%{python3_version}
%else
build build
%endif # with doc
env CFLAGS="$RPM_OPT_FLAGS" \
FFLAGS="$RPM_OPT_FLAGS -fPIC" \
%ifarch %{openblas_arches}
OPENBLAS=%{_libdir} \
%else
ATLAS=%{_libdir}/atlas \
%endif
FFTW=%{_libdir} BLAS=%{_libdir} LAPACK=%{_libdir} \
%__python2 setup.py config_fc \
--fcompiler=gnu95 --noarch \
%if %{with doc}
build_sphinx
rm -r build/sphinx/html/.buildinfo
mv build/sphinx build/sphinx-%{python2_version}
%else
build
%endif # with doc
%if %{with doc}
pushd doc
export PYTHONPATH=$(echo ../build/lib.linux-*-$PY/)
make html SPHINXBUILD=sphinx-build-$PY
rm -rf build/html/.buildinfo
mv build build-$PY
popd
%endif
done
%install %install
env CFLAGS="$RPM_OPT_FLAGS -lm" \ %py3_install
FFLAGS="$RPM_OPT_FLAGS -fPIC" \ %py2_install
%ifarch %{openblas_arches}
OPENBLAS=%{_libdir} \
%else
ATLAS=%{_libdir}/atlas \
%endif
FFTW=%{_libdir} BLAS=%{_libdir} LAPACK=%{_libdir} \
%__python3 setup.py install --root=%{buildroot}
env CFLAGS="$RPM_OPT_FLAGS" \
FFLAGS="$RPM_OPT_FLAGS -fPIC" \
%ifarch %{openblas_arches}
OPENBLAS=%{_libdir} \
%else
ATLAS=%{_libdir}/atlas \
%endif
FFTW=%{_libdir} BLAS=%{_libdir} LAPACK=%{_libdir} \
%__python2 setup.py install --root=%{buildroot}
%check %check
# Skip all tests on s390x because they hangs unexpectedly and randomly # Skip all tests on s390x because they hangs unexpectedly and randomly
@ -221,7 +185,7 @@ popd
%if %{with doc} %if %{with doc}
%files -n python2-scipy-doc %files -n python2-scipy-doc
%license LICENSE.txt %license LICENSE.txt
%doc build/sphinx-%{python2_version}/html %doc doc/build-%{python2_version}/html
%endif # with doc %endif # with doc
%files -n python3-scipy %files -n python3-scipy
@ -232,7 +196,7 @@ popd
%if %{with doc} %if %{with doc}
%files -n python3-scipy-doc %files -n python3-scipy-doc
%license LICENSE.txt %license LICENSE.txt
%doc build/sphinx-%{python3_version}/html %doc doc/build-%{python3_version}/html
%endif # with doc %endif # with doc
%changelog %changelog