Re: Building docs of compiled extensions with new macros

2021-08-18 Thread Miro Hrončok

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}/


--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
___
python-devel mailing list -- python-devel@lists.fedoraproject.org
To unsubscribe send an email to python-devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure


Building docs of compiled extensions with new macros

2021-08-18 Thread Elliott Sales de Andrade
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 
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 
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 
raise ImportError(_msg) from _e
ImportError: pikepdf's extension library failed to import

-- 
Elliott
___
python-devel mailing list -- python-devel@lists.fedoraproject.org
To unsubscribe send an email to python-devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure