Git Product home page Git Product logo

Comments (8)

justinmayer avatar justinmayer commented on July 20, 2024

Hi @sagrotan17. I am sorry to hear that you had a frustrating experience. I will do my best to help you, and at the same time, I will also communicate ways in which to submit more constructive issues in the future.

As a new user to pelican and specially usage of this and other plugins: The information of readme files are really poor

This kind of feedback is not helpful — at all. It is far too vague to be of any value. In the future, please make sure feedback is specific and detailed.

After installation you have to add the plugin to pelicanconf.py -> PLUGINS = [..., "pdf",...].

No, you do not.

What's the problem to add this [piece] of information?

The problem with adding that information is that, as I said, it is not actually necessary in most cases. This is clearly explained in the plugin-related section of the Pelican documentation, and thus we do not usually repeat this information in the README of every single plugin.

That said, in the most minimum manner possible, I have clarified this in the PDF plugin README via: f901db4

It is not the first plugin running into errors and searching for solutions... If there were a little more detailed instructions, beginners like me would run into fewer problems...

Again, this kind of feedback does not help. And in fact, it is worse than that, because this kind of ambiguous comment causes frustration for maintainers, which I imagine was not your intention. Without specific, concrete communication on your part, we simply cannot help you.

Regarding the error you reported, I was able to reproduce it. I can't be certain, but the problem does not seem to have anything to do with Pelican or the PDF plugin. Following is how I investigated, which I include below so it might be useful to you in the future when preparing to submit issues for open-source projects:

  1. Search all of GitHub for: You need xhtml2pdf installed to use the raw HTML directive
  2. Find result for that specific line in the rst2pdf package dependency
  3. Code above that line indicates that error happens when one or more imports fail.
  4. Run python and then try the imports manually. That is: import xhtml2pdf.default, from xhtml2pdf.util import COLOR_BY_NAME, etc.
  5. Notice that the third import fails: from xhtml2pdf.util import memoized
  6. Try the fallback imports in the except ImportError: block, which fails on the first one: from sx.pisa3.pisa_util import COLOR_BY_NAME
  7. If both of those condition blocks fail (and they did, as I said above), then that error message you saw will indeed be triggered.
  8. I then edited rst2pdf/utils.py, commenting out the problematic import and adding the replacement function definition from the fallback import block above as an independent function, after which the error went away, and the PDF was generated successfully:
[…]

def memoized(*a):
            return a


HAS_XHTML2PDF = True
try:
    import xhtml2pdf.default  # NOQA
    from xhtml2pdf.util import COLOR_BY_NAME
    #from xhtml2pdf.util import memoized
    from xhtml2pdf.context import pisaContext
[…]

from pdf.

justinmayer avatar justinmayer commented on July 20, 2024

@wombelix: After reading the above, do you have any idea what might be going on here?

Also, since all tests are currently passing, perhaps a test should be added that would have caught this problem?

from pdf.

wombelix avatar wombelix commented on July 20, 2024

But it is installed (requirements.txt):
xhtml2pdf==0.2.15

@sagrotan17 Can you explain a bit more how you installed pelican and the dependencies?

pip install --user -r requirements.txt ? or did you created a virtual environment and installed pelican in there, like python -m venv venv; source venv/bin/activate; pip install -r requirements.txt? Or maybe via pipx install pelican?

I'm curious how you installed it, depending on the method I might explain some of the challenges you have.

Also, since all tests are currently passing, perhaps a test should be added that would have caught this problem?

@justinmayer let's wait till we understand how pelican and the plugin was installed and where the problems coming from.

from pdf.

justinmayer avatar justinmayer commented on July 20, 2024

@wombelix: I am sorry I was not more clear: I was able to reproduce the error, so I am glad that @sagrotan17 reported it.

I investigated further, and it seems the problem was introduced when xhtml2pdf changed the class name from memoized to Memoized, and rst2pdf has not updated its code to reflect the change when importing it.

In a few hours I will submit a temporary fix for this plugin as well as a PR for the rst2pdf project to fix the import.

from pdf.

justinmayer avatar justinmayer commented on July 20, 2024

@wombelix: On second thought, would you be willing to add a test that fails for the current situation in which this import causes an error?

from pdf.

wombelix avatar wombelix commented on July 20, 2024

I can work on it, just didn't want to get in your way after you said you do it :) still not sure if a unit test is the right thing to do. It seems like an upstream issue as we had it two years before already and did a workaround on our end. I tend to do the same again. Because the unit test would be unpredictable and highly dependent on the installed module versions?

from pdf.

justinmayer avatar justinmayer commented on July 20, 2024

I am also not sure whether a unit test is appropriate, but at the same time it feels uncomfortable to leave things the way they are, where an upstream change like this can silently break the plugin until some hapless user runs into the error and reports it.

So, in a553a33 I took the liberty of creating a functional test instead, in the form of an additional step in the test CI job.

from pdf.

justinmayer avatar justinmayer commented on July 20, 2024

Fix released in PDF 1.0.4

from pdf.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.