I've been experimenting with the new macros for Python packages, and ran into some issues building Sphinx docs for compiled extensions.
When building docs, one usually has to be able to import the project. When the project uses compiled extensions, it is not sufficient to point to the original unpacked sources, but instead must point to the built ones. However, since the new %pyprojec_wheel creates a wheel, I don't know how to do this properly.
Setting e.g., PYTHONPATH=/path/to/*.whl doesn't seem to work (it seems to load everything else but the shared library):
+ pushd docs ~/build/BUILD/pikepdf-2.16.1/docs ~/build/BUILD/pikepdf-2.16.1 ++ ls /builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl + PYTHONPATH=/builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl + sphinx-build-3 . ../html Running Sphinx v4.1.2
Configuration error: There is a programmable error in your configuration file:
Traceback (most recent call last): File "/builddir/build/BUILD/pikepdf-2.16.1/pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl/pikepdf/__init__.py", line 13, in <module> from . import _qpdf ImportError: cannot import name '_qpdf' from partially initialized module 'pikepdf' (most likely due to a circular import) (/builddir/build/BUILD/pikepdf-2.16.1/pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl/pikepdf/__init__.py)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/sphinx/config.py", line 327, in eval_config_file exec(code, namespace) File "/builddir/build/BUILD/pikepdf-2.16.1/docs/conf.py", line 59, in <module> import pikepdf # isort:skip pylint: disable=unused-import File "/builddir/build/BUILD/pikepdf-2.16.1/pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl/pikepdf/__init__.py", line 16, in <module> raise ImportError(_msg) from _e ImportError: pikepdf's extension library failed to import
On 18. 08. 21 11:09, Elliott Sales de Andrade wrote:
I've been experimenting with the new macros for Python packages, and ran into some issues building Sphinx docs for compiled extensions.
When building docs, one usually has to be able to import the project. When the project uses compiled extensions, it is not sufficient to point to the original unpacked sources, but instead must point to the built ones. However, since the new %pyprojec_wheel creates a wheel, I don't know how to do this properly.
Setting e.g., PYTHONPATH=/path/to/*.whl doesn't seem to work (it seems to load everything else but the shared library):
- pushd docs
~/build/BUILD/pikepdf-2.16.1/docs ~/build/BUILD/pikepdf-2.16.1 ++ ls /builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl
- PYTHONPATH=/builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl
- sphinx-build-3 . ../html
Running Sphinx v4.1.2
... ImportError: pikepdf's extension library failed to import
I've run into this in the past as well. I am not yet sure if putting a whl file with extension modules on PYTHONPATH should work or not, but it doesn't.
You should be able to build the docs in %install, after installing the wheel by putting %{buildroot}%{python3_sitearch} to PYTHONPATH. It is a bit weird, but it worked for me in the past.
If that is not desired or working, you can find the built extension in %{_pyproject_builddir}/pip-req-build-*/build/lib.%{python3_platform}-%{python3_version}/
On Wed, 18 Aug 2021 at 19:51, Miro Hrončok mhroncok@redhat.com wrote:
On 18. 08. 21 11:09, Elliott Sales de Andrade wrote:
I've been experimenting with the new macros for Python packages, and ran into some issues building Sphinx docs for compiled extensions.
When building docs, one usually has to be able to import the project. When the project uses compiled extensions, it is not sufficient to point to the original unpacked sources, but instead must point to the built ones. However, since the new %pyprojec_wheel creates a wheel, I don't know how to do this properly.
Setting e.g., PYTHONPATH=/path/to/*.whl doesn't seem to work (it seems to load everything else but the shared library):
- pushd docs
~/build/BUILD/pikepdf-2.16.1/docs ~/build/BUILD/pikepdf-2.16.1 ++ ls /builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl
- PYTHONPATH=/builddir/build/BUILD/pikepdf-2.16.1/docs/../pyproject-wheeldir/pikepdf-2.16.1-cp310-cp310-linux_x86_64.whl
- sphinx-build-3 . ../html
Running Sphinx v4.1.2
... ImportError: pikepdf's extension library failed to import
I've run into this in the past as well. I am not yet sure if putting a whl file with extension modules on PYTHONPATH should work or not, but it doesn't.
You should be able to build the docs in %install, after installing the wheel by putting %{buildroot}%{python3_sitearch} to PYTHONPATH. It is a bit weird, but it worked for me in the past.
It is a bit weird, at least by definition of the stages.
If that is not desired or working, you can find the built extension in %{_pyproject_builddir}/pip-req-build-*/build/lib.%{python3_platform}-%{python3_version}/
That also does work, if a bit undocumented.
It seems that pip may be changing to in-tree builds? https://github.com/pypa/pip/issues/7555 Are we moving towards that as well? It seems like that would make it simpler to build the docs for cases like this.
-- Miro Hrončok -- Phone: +420777974800 IRC: mhroncok
On 19. 08. 21 10:25, Elliott Sales de Andrade wrote:
It seems that pip may be changing to in-tree builds? https://github.com/pypa/pip/issues/7555 Are we moving towards that as well? It seems like that would make it simpler to build the docs for cases like this.
Eventually yes.
On 19. 08. 21 15:45, Miro Hrončok wrote:
On 19. 08. 21 10:25, Elliott Sales de Andrade wrote:
It seems that pip may be changing to in-tree builds? https://github.com/pypa/pip/issues/7555 Are we moving towards that as well? It seems like that would make it simpler to build the docs for cases like this.
Eventually yes.
Coming to rawhide with pip 21.3:
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproje...
I have also resorted to manually installing the wheel to a temporary directory in %build, then setting PYTHONPATH to include the temporary directory to build the documentation. I don’t like this solution very well either, but it is a third alternative that seems to work well. See https://src.fedoraproject.org/rpms/python-asyncpg/blob/ca0bedc42ddba790ffda7... for an example.
python-devel@lists.fedoraproject.org