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

Get rid of lxml dependency #440

Closed
jbremer opened this issue Mar 10, 2017 · 5 comments · Fixed by #485
Closed

Get rid of lxml dependency #440

jbremer opened this issue Mar 10, 2017 · 5 comments · Fixed by #485
Labels
feature New feature that should be supported
Milestone

Comments

@jbremer
Copy link

jbremer commented Mar 10, 2017

If possible, I think it'd be great to get rid of the dependency on lxml. I've found it to be quite annoying to install; on Linux it takes a minute to compile, on Mac OS X the first time it'll take like an hour to compile (due to having to brew install gcc as well), and on Windows one by default doesn't have a compiler at hand - leaving you to install a pre-compiled version of lxml, but apparently not every version has pre-compiled DLLs in place..
By replacing lxml by stdlib xml some of this pain (imo) goes away. Of course will need some simple unittests to ensure compatibility remains, but other than that.. :)

@liZe
Copy link
Member

liZe commented Mar 10, 2017

By replacing lxml by stdlib xml some of this pain (imo) goes away. Of course will need some simple unittests to ensure compatibility remains, but other than that.. :)

Unfortunately, that's not true. WeasyPrint uses lxml because it supports XPath for CSS selectors coming from cssselect, and there's nothing in the standard library that supports XPath correctly.

lxml has also lots of wheels that should avoid compilation on many platforms.

But yes, avoiding lxml is a good idea. @SimonSapin had started cssselect2 to make CSS selectors work without XPath, but it's dead today.

@liZe liZe added the feature New feature that should be supported label Mar 10, 2017
@jbremer
Copy link
Author

jbremer commented Mar 10, 2017

Yes, I see, that does complicate things :( I guess usage of weasyprint will have to remain an optional feature for me right now then. Thanks for the feedback!

@SimonSapin
Copy link
Member

pip’s integration/usage of wheel files has made a lot of progress if the last few years. These days pip install lxml on Linux uses a pre-compiled wheel that installs quickly.

@faststare
Copy link

use optional html5lib instead. because lxml dependency will limit your user base.

@SimonSapin
Copy link
Member

@faststare, see @liZe’s message above:

WeasyPrint uses lxml because it supports XPath for CSS selectors coming from cssselect

So moving away from lxml first requires moving away from XPath. Which we want to do anyway, but it’ll take more work than "just switch to html5lib".

@liZe liZe closed this as completed in #485 Jul 11, 2017
@liZe liZe added this to the v0.40 milestone Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants