Skip to content

path is deprecated. #540

@Carreau

Description

@Carreau

Describe the bug

I was building scipy docs and got greeted with a

Traceback (most recent call last):
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/sphinx/application.py", line 223, in __init__
    self.setup_extension(extension)
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/sphinx/application.py", line 398, in setup_extension
    self.registry.load_extension(self, extname)
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/sphinx/registry.py", line 472, in load_extension
    metadata = setup(app)
               ^^^^^^^^^^
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/myst_nb/__init__.py", line 10, in setup
    return sphinx_setup(app)
           ^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/myst_nb/sphinx_ext.py", line 98, in sphinx_setup
    add_css(app)
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/site-packages/myst_nb/sphinx_ext.py", line 189, in add_css
    with import_resources.path(static, "mystnb.css") as source_path:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bussonniermatthias/miniforge3/envs/scipy-dev/lib/python3.11/importlib/resources/_legacy.py", line 18, in wrapper
    warnings.warn(
DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.

path() appear to still be there:

with import_resources.path(static, "mystnb.css") as source_path:
hash = _get_file_hash(source_path)
app.add_css_file(f"mystnb.{hash}.css")

Reproduce the bug

Will try to make a minimal reproducible example, I just want to log the issue before I forget.

List your environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions