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

Remove pkg_resources for reading style.css #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Tronic
Copy link
Member

@Tronic Tronic commented Dec 6, 2023

Fix #9. Needs testing & review.

Fix #9. Needs testing & review.
@felixonmars
Copy link

This appears to be broken for me:

$ python -c "import tracerite"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.11/site-packages/tracerite/__init__.py", line 1, in <module>
    from .html import html_traceback
  File "/usr/lib/python3.11/site-packages/tracerite/html.py", line 7, in <module>
    style = files(__name__).join_path("style.css").read_text(encoding="UTF-8")
            ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 22, in files
    return from_package(get_package(package))
                        ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/resources/_common.py", line 55, in get_package
    raise TypeError(f'{package!r} is not a package')
TypeError: 'tracerite.html' is not a package

While the old version works fine here.

from html5tagger import E

from .trace import extract_chain

style = pkg_resources.resource_string(__name__, "style.css").decode()
style = files(__name__).join_path("style.css").read_text(encoding="UTF-8")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
style = files(__name__).join_path("style.css").read_text(encoding="UTF-8")
style = files(__package__).joinpath("style.css").read_text(encoding="UTF-8")

This way it works for me.

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

Successfully merging this pull request may close these issues.

setuptools dependency
3 participants