Use lxml-library in a plugin

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Dan Dare Offline
http://www.xbmc4xbox.org
Posts: 1,054
Joined: Sep 2004
Reputation: 146
Post: #11
I think that's already possible by adding libraries into XBMC\system\python\lib, that's what the readme.txt in there says:

Lib dir:
Library directory used by python.
Here can new packages or modules be installed by the user.

But still, who's going to maintain those libraries, build them and make sure they they work for each platform?
find quote
queeup Offline
Fan
Posts: 734
Joined: Feb 2009
Reputation: 15
Post: #12
Yes I know that but if we need to install with SVN repo we need special://home/system/python for that. On special://xbmc/system/python users not have permission on Linux and Windows without admin account.
Quote:But still, who's going to maintain those libraries, build them and make sure they they work for each platform?
It's not a big deal. I have already lxml for all platforms and for python 2.4 I mean working with XBMC. Not to many libraries need it. Like i said. Most important libraries are Feedparser, BeautifulSoup and lxml (Its my opinion.) If we do it we don't need librarys in our plugins. Your and mine plugins have same Beautifulsoup library and we have total 10-12 same library installed on our harddisk.
find quote
Dan Dare Offline
http://www.xbmc4xbox.org
Posts: 1,054
Joined: Sep 2004
Reputation: 146
Post: #13
@queeup
I completely agree with you on that, but what happens if two plugins need two versions of the library? Smile I have a couple of plugins that don't work with the latest version of BeautifulSoup, I had to revert to using the previous one.

I agree though, it would be much easier if these libraries would be delivered with XBMC, or why not even your enhancement would work.
find quote
queeup Offline
Fan
Posts: 734
Joined: Feb 2009
Reputation: 15
Post: #14
Yes I prefer BeautifulSoup 3.0.7a also.
Quote:but what happens if two plugins need two versions of the library?
If your plugin need it never version, you can always add in to your plugin folder and import from there. Am I wrong?
find quote
rwparris2 Offline
Team-XBMC Python Developer
Posts: 1,341
Joined: Jan 2008
Reputation: 2
Location: US
Post: #15
The current way of doing it is the safest.
10 copies of BeautifulSoup is less than 1mb...

Always read the XBMC online-manual, FAQ and search and search the forum before posting.
For troubleshooting and bug reporting please read how to submit a proper bug report.

If you're interested in writing addons for xbmc, read docs and how-to for plugins and scripts ||| http://code.google.com/p/xbmc-addons/
find quote
cancan101 Offline
Donor
Posts: 46
Joined: Sep 2010
Reputation: 0
Post: #16
I was able to get lxml to work on Dharma + Ubuntu 11.10 x86-64 by extracting the contents of the following RPM to /usr/share/xbmc/system/python/lib/python2.4/ (specifically the directory within the RPM: /./usr/lib64/python2.4/site-packages/lxml/)

I tried a few other RPMs that I found but they either were rejected by python (ImportError) or they caused XBMC to die. This one works like a charm.

I would prefer to not need lxml, unfortunately I am using a library that depends upon it. I would be willing to sacrifice speed for a full python implementation. In Python 2.5 (Dharma is 2.4), there is xml.etree.ElementTree.fromstring for XML parsing, but there is no comparable lxml.html.document_fromstring. BeautifulSoup is a great library, unfortunately the API is different from lxml so it is not a drop in replacement.

Any thoughts on a full python implementation of lxml's API (especially lxml.html)?
find quote
giftie Online
Skilled Python Coder
Posts: 2,036
Joined: Mar 2010
Reputation: 35
Post: #17
cancan101 Wrote:I was able to get lxml to work on Dharma + Ubuntu 11.10 x86-64 by extracting the contents of the following RPM to /usr/share/xbmc/system/python/lib/python2.4/ (specifically the directory within the RPM: /./usr/lib64/python2.4/site-packages/lxml/)

I tried a few other RPMs that I found but they either were rejected by python (ImportError) or they caused XBMC to die. This one works like a charm.

I would prefer to not need lxml, unfortunately I am using a library that depends upon it. I would be willing to sacrifice speed for a full python implementation. In Python 2.5 (Dharma is 2.4), there is xml.etree.ElementTree.fromstring for XML parsing, but there is no comparable lxml.html.document_fromstring. BeautifulSoup is a great library, unfortunately the API is different from lxml so it is not a drop in replacement.

Any thoughts on a full python implementation of lxml's API (especially lxml.html)?

Since this is an external library(it is not part of the default python) there is two ways to bring the module into your addon. First you can physically add it to your addon(ie resources/lib/lxml/) or secondly XBMC has an addon called script.module, this is where you can put the module into. This is how BeautifulSoup is created.

[Image: e4f63e45ba34fe4695b3bb08eb2499d8e4ee484e...4c076g.jpg]
For troubleshooting and bug reporting please make sure you read this first you can also use XBMC Log Uploader Script.
Cinema Experience
Cinema Experience Wiki
cdART Manager
fanart.tv


find quote
cancan101 Offline
Donor
Posts: 46
Joined: Sep 2010
Reputation: 0
Post: #18
My question is if anyone knows of a Python implementation of the lxml API?

I just wanted to see if it were possible to use the binary lxml library from XBMC and it is possible, but this is not a good solution (I would need to distribute binaries of that library with the plugin).

What I want is something like BeautifulSoup that I can use as a drop in replacement for lxlml.
find quote
queeup Offline
Fan
Posts: 734
Joined: Feb 2009
Reputation: 15
Post: #19
some discussions:
http://trac.xbmc.org/ticket/11189
http://forum.xbmc.org/showthread.php?tid...light=lxml
find quote
giftie Online
Skilled Python Coder
Posts: 2,036
Joined: Mar 2010
Reputation: 35
Post: #20
queeup Wrote:some discussions:
http://trac.xbmc.org/ticket/11189
http://forum.xbmc.org/showthread.php?tid...light=lxml

This looks like it needs to be moved to a pull request.

[Image: e4f63e45ba34fe4695b3bb08eb2499d8e4ee484e...4c076g.jpg]
For troubleshooting and bug reporting please make sure you read this first you can also use XBMC Log Uploader Script.
Cinema Experience
Cinema Experience Wiki
cdART Manager
fanart.tv


find quote
Post Reply