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

RuntimeError: absolute path '.../dataclasses.py' is not a descendant of the current working directory or of the system's python library #456

Open
Lucas-C opened this issue Feb 23, 2025 · 1 comment

Comments

@Lucas-C
Copy link
Contributor

Lucas-C commented Feb 23, 2025

Hi.

In fpdf2 we have been using pdoc3 for several years:
thank you for maintaining this great tool!

I noticed a warning in our execution log:
https://github.com/py-pdf/fpdf2/actions/runs/13482969652/job/37670544099?pr=1374

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/pdoc/html_helpers.py", line 569, in format_git_link
    path = _project_relative_path(abs_path)
  File "/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/pdoc/html_helpers.py", line 635, in _project_relative_path
    raise RuntimeError(
    ...<2 lines>...
    )
RuntimeError: absolute path '/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/dataclasses.py' is not a descendant of the current working directory or of the system's python library.

I do not quite understand the origin of this stacktrace,
but I suspect that's maybe due to this usage of dataclasses.replace as a method:
https://github.com/py-pdf/fpdf2/blob/2.8.2/fpdf/fonts.py#L75

Do you know how we could prevent this error to be raised?

@kernc
Copy link
Member

kernc commented Feb 24, 2025

pdoc/pdoc/html_helpers.py

Lines 628 to 638 in 9e4f6ad

from sysconfig import get_path
libdir = get_path("platlib")
for prefix_path in (_git_project_root() or os.getcwd(), libdir):
common_path = os.path.commonpath([prefix_path, absolute_path])
if os.path.samefile(common_path, prefix_path):
# absolute_path is a descendant of prefix_path
return os.path.relpath(absolute_path, prefix_path)
raise RuntimeError(
f"absolute path {absolute_path!r} is not a descendant of the current working directory "
"or of the system's python library."
)

The question seems to be, why isn't '/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/' recognized/configured as 'platlib' path.

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

No branches or pull requests

2 participants