Use lxml-library in a plugin
#1
I have a python script running on a python installation with lxml. How could I import the lxml to use it in a xbmc plugin?

Thanks
Reply
#2
Please help me with this. I'm getting crazy...

Thanks
Reply
#3
elementtree uses the same syntax and will be a billion times easier to distribute.

If you don't want to use elementtree... you'll have to distribute and install setuptools in your addon for all three, see http://pypi.python.org/pypi/setuptools for how to install in xbmc's python, then easy_install lxml to xbmc's python. It will also require users to already have libxslt & whatever other prerequisites lxml has installed.

Basically, use elementtree instead.
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/
Reply
#4
Yes, same advice than rwparris2, give a try to ET, it is a very lib and you just need to provide it with your script. I gave you an example on how to use it on your previous post when you were asking which XML parser were available.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#5
@kimx
One solution is to include the package source as part as your plugin and then add the path with code like:

PHP Code:
LIB_DIR xbmc.translatePathos.path.joinos.getcwd(), 'resources''lib' ) )
sys.path.append (LIB_DIR

and then you can use an import statement.

See some of the plugins plugins in my signature, they include things like BeautifulSoup or simpljason. An alternative is to use xml.dom to parse XMLs, see XBMC Xbox Trac Changelog or XBMC Zone Installer.
Reply
#6
Thank you for the answers, but the problem is not how to import, but which files I need to import the lib. In my script I use the etree element from lxml. In a normal python install I use this statement to import it:
Code:
from lxml import etree
How could I get the same result in xbmc and which files are needed?
Thanks in advance
Reply
#7
You could download the source for lxml (http://pypi.python.org/pypi/lxml/) and pick the contents of the src folder, but somehow I have a feeling they won't work without compiling them for a particular platform... I would try to rewrite the logic you have using the other suggested alternatives...
Reply
#8
yes it wont work without compiling. It's depends Os and Python version also. For exmple if you use lxml with your XBMC plugin you should add lxml for all platforms separately (Linux,win32,Os X) and python version must be 2.4. This is huge for 1 plugin. Its approximately 6mb Smile

One more thing, for example you have windows and your python version 2.6 and you developing plugins in this computer. You need lxml for windows and python version for 2.6 but when you release plugin you need lxml for all platforms and for python 2.4.
Reply
#9
I'd say - it would make sense to create a Trac request to include the appropriate lxml with Python with XBMC, but given that XBMC Team is concentrated on other tasks now, I don't see that happening soon. While there are other libraries already available with XBMC Python (xml.dom) or out there that could to the same task, the only reason I would against re-writing away from lxml is what, convenience?!
Reply
#10
I think this is the easiest way to do it. http://trac.xbmc.org/ticket/7246
Reply
#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?
Reply
#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.
Reply
#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.
Reply
#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?
Reply
#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/
Reply

Logout Mark Read Team Forum Stats Members Help
Use lxml-library in a plugin0