Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

autosignature warnings + complicated setup #319

Open
myselfhimself opened this issue Oct 22, 2020 · 8 comments
Open

autosignature warnings + complicated setup #319

myselfhimself opened this issue Oct 22, 2020 · 8 comments

Comments

@myselfhimself
Copy link

Hello,

I would like to remove warnings mostly. I describe my setup below:

I am trying this in a .rst file for the gmic-py purely compiled C/C++ Python binding which has C docstrings:

.. autosignature:: gmic.GmicImage.from_PIL
:nosummary:
:debug:

For it to work I had to do three things:

  • add pyquickhelper and sphinxcontrib.imagesvg to my docs/'s requirements.txt
  • add import gmic and add pyquickhelper.sphinxext.sphinx_autosignature to the extensions array variable, within my docs/conf.py

after this, when building HTML with sphinx, I get the following log with warnings regarding a package import attempt:

(numpy291) {  } AAA@N302L-G18F04:~/Productions/GMIC/gmic-py$ 
$ bash build_tools.bash 6b_make_doc_without_c_recompilation
🐯 Targeting G'MIC 2.9.1 (gmic.eu) as package 2.9.1-alpha2🐯
Found existing installation: gmic 2.9.1a1
Uninstalling gmic-2.9.1a1:
  Successfully uninstalled gmic-2.9.1a1
Processing ./dist/gmic-2.9.1a1-cp37-cp37m-linux_x86_64.whl
Requirement already satisfied: wurlitzer in /export/home/AAA/.virtualenvs/numpy291/lib/python3.7/site-packages (from gmic==2.9.1a1) (2.0.1)
Installing collected packages: gmic
Successfully installed gmic-2.9.1a1
WARNING: You are using pip version 20.2.2; however, version 20.2.4 is available.
You should consider upgrading via the '/export/home/AAA/.virtualenvs/numpy291/bin/python3.7 -m pip install --upgrade pip' command.
Sphinx v3.2.1 en cours d'exécution
chargement de l'environnement pickled... fait
construction en cours [mo]:cibles pour les fichiers po 0 qui sont périmées
construction [html]:cibles pour les fichiers sources 7 qui sont périmées
mise-à-jour de l'environnement :0 ajouté, 7 modifié, 0 supprimé
OUTPUT FILENAME gmic_sphinxpuvos1js/5e1f69be-147c-11eb-9e0e-8cec4b8c0881.png                                                                                   
WILL RUN /export/home/AAA/.virtualenvs/numpy291/lib/python3.7/site-packages/gmic_sphinx/samples/sample_earth.png blur 4 output gmic_sphinxpuvos1js/5e1f69be-147c-11eb-9e0e-8cec4b8c0881.png
OUTPUT FILENAME gmic_sphinxpuvos1js/5e1f69bf-147c-11eb-9e0e-8cec4b8c0881.png
WILL RUN /export/home/AAA/.virtualenvs/numpy291/lib/python3.7/site-packages/gmic_sphinx/samples/sample_earth.png blur 4 output gmic_sphinxpuvos1js/5e1f69bf-147c-11eb-9e0e-8cec4b8c0881.png
OUTPUT FILENAME gmic_sphinxpuvos1js/5e1f69c0-147c-11eb-9e0e-8cec4b8c0881.png
WILL RUN /export/home/AAA/.virtualenvs/numpy291/lib/python3.7/site-packages/gmic_sphinx/samples/sample_earth.png blur 4 fx_bokeh 3,8,0,30,8,4,0.3,0.2,210,210,80,160,0.7,30,20,20,1,2,170,130,20,110,0.15,0 output gmic_sphinxpuvos1js/5e1f69c0-147c-11eb-9e0e-8cec4b8c0881.png
lecture des sources... [100%] numpy                                                                                                                            
WARNING: [autosignature] unable to import 'gmic.GmicImage.from_PIL' due to 'Unable to import 'gmic.GmicImage.from_PIL'. Exceptions met: function-<class 'RuntimeError'>-Unable to compile and execute 'from gmic.GmicImage import from_PIL\nmyfunc = from_PIL' due to  No module named 'gmic.GmicImage'; 'gmic' is not a package given: gmic.GmicImage.from_PIL ### method-<class 'TypeError'>-'gmic.GmicImage.from_PIL' is not a method - <built-in method from_PIL of type object at 0x7ff9c43e6ee0> ### staticmethod-<class 'TypeError'>-'gmic.GmicImage.from_PIL' is not a static method - <built-in method from_PIL of type object at 0x7ff9c43e6ee0> ### property-<class 'TypeError'>-'gmic.GmicImage.from_PIL' is not a property(*) - <built-in method from_PIL of type object at 0x7ff9c43e6ee0> ### class-<class 'RuntimeError'>-Unable to compile and execute 'from gmic.GmicImage import from_PIL\nmyfunc = from_PIL' due to  No module named 'gmic.GmicImage'; 'gmic' is not a package given: gmic.GmicImage.from_PIL'
WARNING:    File "/export/home/AAA/Productions/GMIC/gmic-py/docs/PIL.rst", line 8
WARNING: [autosignature] object 'gmic.GmicImage.from_PIL' cannot be imported.
recherche des fichiers périmés... aucun résultat
environnement de sérialisation... fait
vérification de la cohérence... fait
document en préparation... fait
écriture... [100%] numpy                                                                                                                                       
generating indices...  genindex py-modindexfait
writing additional pages...  searchfait
copie des images... [100%] gmic_sphinxpuvos1js/5e1f69c0-147c-11eb-9e0e-8cec4b8c0881.png                                                                        
copie des fichiers statiques... ... fait
copying extra files... fait
dumping search index in English (code: en)... fait
dumping object inventory... fait
build a réussi, 3 warnings.

Les pages HTML sont dans _build/html .

the result is:
image

How do I:

  • simplify the setup (namely import gmic in conf.py is strange.. but all is OK for me)
  • remove the warnings ?

Thanks for your help!

@myselfhimself
Copy link
Author

Here is a readthedocs.io failing build:

 Running Sphinx v1.8.5
loading translations [en]... done

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 472, in load_extension
    mod = __import__(extname, None, None, ['setup'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/pyquickhelper/sphinxext/__init__.py", line 34, in <module>
    from .sphinx_tocdelay_extension import TocDelayDirective, tocdelay_node
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/pyquickhelper/sphinxext/sphinx_tocdelay_extension.py", line 12, in <module>
    from sphinx.errors import NoUri
ImportError: cannot import name 'NoUri' from 'sphinx.errors' (/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/errors.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 303, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 228, in __init__
    self.setup_extension(extension)
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 449, in setup_extension
    self.registry.load_extension(self, extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/registry.py", line 475, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname, err)
sphinx.errors.ExtensionError: Could not import extension pyquickhelper.sphinxext.sphinx_autosignature (exception: cannot import name 'NoUri' from 'sphinx.errors' (/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/errors.py))

Extension error:
Could not import extension pyquickhelper.sphinxext.sphinx_autosignature (exception: cannot import name 'NoUri' from 'sphinx.errors' (/home/docs/checkouts/readthedocs.org/user_builds/gmic-py/envs/latest/lib/python3.7/site-packages/sphinx/errors.py)) 

@myselfhimself
Copy link
Author

OK sorry the above readthedocs.io error is due to an old sphinx version by default on this platform, I managed to overcome it..

@myselfhimself
Copy link
Author

OK autosignature is now used at https://gmic-py.readthedocs.io/en/latest/PIL.html for the first two black links
I have decided to ignore the warnings for now..

@sdpython
Copy link
Owner

sdpython commented Nov 9, 2020

To fix it, I would probably add a parameter in conf.py to disable warnings. Would that be ok for you?

@myselfhimself
Copy link
Author

yes

@myselfhimself
Copy link
Author

Thank you

@sdpython
Copy link
Owner

I looked into the code and the logging [import_object] ... should not appear unless :debug: is added as on option to the directive. The warning WARNING: [autosignature] should not appear unless the directive does not work. I looked at https://gmic-py.readthedocs.io/en/latest/PIL.html and it looks ok. I guess I'll have to build and run the documentation to fully understand what's happening.

@myselfhimself
Copy link
Author

myselfhimself commented Nov 12, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants