Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with case sensitivity on MacOS X #73

Open
astrofrog opened this issue Apr 3, 2019 · 9 comments
Open

Issue with case sensitivity on MacOS X #73

astrofrog opened this issue Apr 3, 2019 · 9 comments
Labels

Comments

@astrofrog
Copy link
Member

Astropy has M_bol and m_bol objects in the same sub-package, and this causes issues when using sphinx-automodapi because MacOS X is case-insensitive meaning that the .rst pages for each of these objects will conflict:

/Users/tom/Dropbox/Code/Astropy/astropy/docs/index.rst:: WARNING: toctree contains reference to nonexisting document 'api/astropy.units.function.logarithmic.m_bol'
/Users/tom/Dropbox/Code/Astropy/astropy/docs/index.rst:: WARNING: toctree contains reference to nonexisting document 'api/astropy.units.function.logarithmic.m_bol'
/Users/tom/Dropbox/Code/Astropy/astropy/docs/units/index.rst:389:<autosummary>:1: WARNING: py:obj reference target not found: astropy.units.function.logarithmic.m_bol
/Users/tom/Dropbox/Code/Astropy/astropy/docs/units/index.rst:: WARNING: toctree contains reference to nonexisting document 'api/astropy.units.function.logarithmic.m_bol'
/Users/tom/Dropbox/Code/Astropy/astropy/docs/units/index.rst:389:<autosummary>:: WARNING: toctree contains reference to nonexisting document 'api/astropy.units.function.logarithmic.m_bol'
/Users/tom/Dropbox/Code/Astropy/astropy/docs/units/logarithmic_units.rst:244:<autosummary>:1: WARNING: py:obj reference target not found: astropy.units.function.logarithmic.m_bol
/Users/tom/Dropbox/Code/Astropy/astropy/docs/units/logarithmic_units.rst:244:<autosummary>:: WARNING: toctree contains reference to nonexisting document 'api/astropy.units.function.logarithmic.m_bol'
@astrofrog astrofrog added the bug label Apr 3, 2019
@tonigi
Copy link

tonigi commented Aug 30, 2019

Hit this too. Perhaps there could be an option which causes file names to be rewritten (say, appending an underscore after each capital letter)?

@pllim
Copy link
Member

pllim commented Dec 22, 2021

Apple should just make their stuff be case sensitive. I don't see how we can fix this.

@pllim pllim closed this as completed Dec 22, 2021
@pllim pllim added the wontfix label Dec 22, 2021
@bsipocz
Copy link
Member

bsipocz commented Dec 22, 2021

@pllim - I think we could maybe add a warning on osx, if there was any such sphinx warnings that say that some of the above might have been caused due to case sensitivity. As I recall it was a bit of a puzzle when we first run into the problem, such a warning would save a bit of time for anyone freshly running into it.

@pllim pllim reopened this Dec 22, 2021
@pllim pllim changed the title Issue with case sensitivity on MacOS X Issue with case sensitivity on MacOS X (document this somewhere) Dec 22, 2021
@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2023

This has bitten me again, now with pyvo where we have classes like pyvo.auth.authsession.AuthSession. This generates warnings like these (via autodoc):

WARNING: autodoc: failed to import method 'AuthSession.add_security_method_for_url' from module 'pyvo.auth'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/sphinx/util/inspect.py", line 440, in safe_getattr
    return getattr(obj, name, *defargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pyvo.auth.AuthSession' has no attribute 'add_security_method_for_url'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/sphinx/ext/autodoc/importer.py", line 102, in import_object
    obj = attrgetter(obj, mangled_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/sphinx/ext/autodoc/__init__.py", line 327, in get_attr
    return autodoc_attrgetter(self.env.app, obj, name, *defargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/sphinx/ext/autodoc/__init__.py", line 2827, in autodoc_attrgetter
    return safe_getattr(obj, name, *defargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bsipocz/.pyenv/versions/3.11.0/lib/python3.11/site-packages/sphinx/util/inspect.py", line 456, in safe_getattr
    raise AttributeError(name) from exc
AttributeError: add_security_method_for_url

/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.add_security_method_for_url
/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.delete
/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.get
/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.post
/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.put
/Users/bsipocz/munka/devel/pyvo/docs/api/pyvo.auth.AuthSession.rst:19:<autosummary>:1: WARNING: py:obj reference target not found: pyvo.auth.AuthSession.AuthSession.update_from_capabilities

and an rst file like this:

AuthSession
===========

.. currentmodule:: pyvo.auth

.. autoclass:: AuthSession
   :show-inheritance:

   .. rubric:: Methods Summary

   .. autosummary::

      ~AuthSession.add_security_method_for_url
      ~AuthSession.delete
      ~AuthSession.get
      ~AuthSession.post
      ~AuthSession.put
      ~AuthSession.update_from_capabilities

   .. rubric:: Methods Documentation

   .. automethod:: add_security_method_for_url
   .. automethod:: delete
   .. automethod:: get
   .. automethod:: post
   .. automethod:: put
   .. automethod:: update_from_capabilities

@bsipocz bsipocz removed the wontfix label Jan 27, 2023
@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2023

Note, this case is someone different from the m_bol vs M_bol, as there is only one AuthSession class, and it's exposed in the auth.AuthSession namespace, there is no need for having anything for the authsession.py module...

@bsipocz bsipocz changed the title Issue with case sensitivity on MacOS X (document this somewhere) Issue with case sensitivity on MacOS X Jan 27, 2023
@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2023

OK, same stuff different phrasing: sphinx-doc/sphinx#1495

@bsipocz
Copy link
Member

bsipocz commented Jan 27, 2023

And here is a patch that maybe useful for us, too?: scikit-learn/scikit-learn#13022

@HealthyPear
Copy link

Hello!

I think I got the same issue as @bsipocz where I am using macos with sphinx-automodapi v0.14.1 and sphinx 5.3.0.

In my package I have a module pyswgo.io.eventsource which contains the class EventSource with a (static) method called is_compatible and when I compile the docs I get for example

WARNING: autodoc: failed to import method 'EventSource.is_compatible' from module 'pyswgo.io'; the following exception was raised:
Traceback (most recent call last):
  File "/Users/michele/Applications/mambaforge/envs/pyswgo/lib/python3.9/site-packages/sphinx/util/inspect.py", line 376, in safe_getattr
    return getattr(obj, name, *defargs)
AttributeError: module 'pyswgo.io.EventSource' has no attribute 'is_compatible'

/Users/michele/Applications/SWGO/irf-production/docs/api/pyswgo.io.EventSource.rst:30:<autosummary>:1: WARNING: py:obj reference target not found: pyswgo.io.EventSource.EventSource.is_compatible

Is this the same issue?

I know of the existence of the autosummary_filename_map and I naïvely tested it as

autosummary_filename_map = {"pyswgo.io.eventsource.Eventsource": "EventSource"}

right after the extensions dictionary in conf.py, but to no use.

Is there any news about this issue?

If for some reason my problem is of a different nature I will gladly bother your with a new issue :)

@bsipocz
Copy link
Member

bsipocz commented Mar 13, 2023

I tried a bit of autosummary_filename_map but it didn't work out of the box for the pyvo case above, and I haven't dug deep enough yet to see what needed to be fixed for automodapi to allow it to work.
To be practical, ultimately I may just go ahead and rename or merge the files that have the same names as the single class they contain.

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

No branches or pull requests

5 participants