View previous topic :: View next topic |
Author |
Message |
turtles Veteran
Joined: 31 Dec 2004 Posts: 1655
|
Posted: Fri Nov 09, 2018 7:04 pm Post subject: running custom script; How to find gentoo python deps? |
|
|
Greetings all.
I need to run what I think is a python2 script that requires the following python modules:
Code: | from zipfile import ZipFile
from xml.dom.minidom import parseString
from zlib import decompress
import Image
from os import system,sep
from sys import argv
from reportlab.pdfgen import canvas
from io import BytesIO
from reportlab.pdfbase.pdfutils import ImageReader
from re import sub
from tempfile import gettempdir
import webbrowser |
How can I painlessly match these to ebuilds needed to emerge?
Thanks!
Edit: well changing the line import Image to Code: | from PIL import Image | got rid of the error I was getting. _________________ Donate to Gentoo |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21607
|
Posted: Sat Nov 10, 2018 1:07 am Post subject: |
|
|
Asking us to solve it for you is pretty painless. Python imports are satisfied by files with a name related to what is imported. In the general case, your question is a variant of "How do I find what package installs file FOO, given that it is not installed and therefore I cannot use equery belongs on it?" The general answer is to consult a search engine, consult the community-maintained package file list, or try to guess it from package names.
In the interest of being a bit more helpful: Code: | >>> __import__("zipfile")
<module 'zipfile' from '/usr/lib64/python2.7/zipfile.pyc'>
>>> __import__("xml")
<module 'xml' from '/usr/lib64/python2.7/xml/__init__.pyc'>
>>> __import__("zlib")
<module 'zlib' from '/usr/lib64/python2.7/lib-dynload/zlib.so'>
>>> __import__("os")
<module 'os' from '/usr/lib64/python2.7/os.pyc'>
>>> __import__("sys")
<module 'sys' (built-in)>
>>> __import__("io")
<module 'io' from '/usr/lib64/python2.7/io.pyc'>
>>> __import__("re")
<module 're' from '/usr/lib64/python2.7/re.pyc'>
>>> __import__("tempfile")
<module 'tempfile' from '/usr/lib64/python2.7/tempfile.pyc'>
>>> __import__("webbrowser")
<module 'webbrowser' from '/usr/lib64/python2.7/webbrowser.pyc'>
| As a built-in, sys is obviously part of Python. For all the others, I asked equery belongs, and it says they too are provided by dev-lang/python.
I don't have modules for Image or reportlab. If I had to guess, I would say that the cleverly named dev-python/reportlab will provide reportlab. Image is a bit harder since it is generic, but I guessed that it would come from the Python Image Library (PIL), and the documentation for dev-python/pillow (a PIL fork) says I am correct.
Therefore, of all the imports shown, only reportlab and Image require anything other than your core Python install. For those two, you likely want dev-python/reportlab and dev-python/pillow. Remember to set their PYTHON_TARGETS for the version of Python that will run this script. Otherwise, you won't have compatible modules and the imports will fail even after you install the package. |
|
Back to top |
|
|
turtles Veteran
Joined: 31 Dec 2004 Posts: 1655
|
Posted: Sat Nov 10, 2018 3:32 am Post subject: |
|
|
Thank you Hu! I just wanted to make sure Gentoo did not have some slick tool like g-cpan.
My main work scripting language tool is Perl and I can use Gentos's app-portage/g-cpan to get any Perl script working in under 5 minutes.
if a perl script contains Code: | use Rose::DB::Object
|
All I need to do is Code: | g-cpan -i Rose::DB::Object |
Its odd that Gentoo is so Python based and does not have a similar tool.
But alas its odd to me that anyone would want to use a language where indentation tabs and white-space means something that would throw a compile time error.
Cheers
Turtle _________________ Donate to Gentoo |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|