How can I find the python package to satisfy a missing python script dependency?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I find the python package to satisfy a missing python script dependency?

Dave Plater lst
The script with this header works on my local machine but fails in obs,
how can I find the python package that provides xml.etree.ElementTree :

import xml.etree.ElementTree as etree
import os
import shutil
import re
from subprocess import call

I've googled xml.etree.ElementTree and found that it exists as
ElementTree.py, from that I used find to locate it under
/usr/lib64/python2.7/ and used rpm to locate the package which turns out
to be "python-xml" but I thought that maybe there was a python tool that
could parse the headers and give me the package name.

Thanks

Dave P

--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I find the python package to satisfy a missing python script dependency?

jan matejek-4
On 9.1.2017 11:00, Dave Plater wrote:
> The script with this header works on my local machine but fails in obs,
> how can I find the python package that provides xml.etree.ElementTree :
>
> import xml.etree.ElementTree as etree

if you have a machine where the necessary package is installed, you can
do this:

$ python2
>>> import xml.etree.ElementTree
>>> xml.etree.ElementTree.__file__
'/usr/lib64/python2.7/xml/etree/ElementTree.pyc'

ask rpm about this file and it will give you the right package.

There is an alternate spelling of "import": "from A.B.C import D"
In that case, you can't generally ask about D.__file__, so instead
"import A.B.C" and ask about "A.B.C.__file__".

I don't think there is a general tool to do this. It might be worth
writing one for situations where you're looking for a package that you
don't have installed. There's some work in Fedora that I'm looking to
adopt, to automatically figure out pythonic dependencies.

m.



signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How can I find the python package to satisfy a missing python script dependency?

Christian Boltz-5
Hello,

Am Montag, 9. Januar 2017, 15:47:27 CET schrieb jan matejek:
> On 9.1.2017 11:00, Dave Plater wrote:
> > The script with this header works on my local machine but fails in
> > obs, how can I find the python package that provides
> > xml.etree.ElementTree :
> >
> > import xml.etree.ElementTree as etree
...
> I don't think there is a general tool to do this. It might be worth
> writing one for situations where you're looking for a package that you
> don't have installed. There's some work in Fedora that I'm looking to
> adopt, to automatically figure out pythonic dependencies.

There is a very generic tool that might help - pin ;-)

First, get ARCHIVES.gz for your openSUSE version, for example
http://download.opensuse.org/distribution/leap/42.2/repo/oss/ARCHIVES.gz
and save it in /var/lib/pin/

Then run
    pin 'xml.etree.ElementTree.*py'
and pin will grep for that in ARCHIVES.gz.

Note that the actual path actually contains xml/etree/ElementTree.py or
xml/etree/ElementTree/__init__.py, which is why I proposed to use ".*py"
and not just ".py". (Of course, you can search without the ".*py", but
that might give you false positives.) Also, the dots are actually
slashes, but a regex-dot matches any char which makes things a bit
easier ;-)


Regards,

Christian Boltz
--
Woher soll Wine denn wissen, welches Programm Du aufrufen willst? Das
BRAIN (I know what you are thinking) Interface fehlt bei Linux leider
noch und ich persönlich steh auch nicht so drauf, mir Kabel in den
Schädel zu stecken.              [Philipp Zacharias in suse-linux]

--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I find the python package to satisfy a missing python script dependency?

Dave Plater lst
In reply to this post by jan matejek-4


On 09/01/2017 16:47, jan matejek wrote:

> On 9.1.2017 11:00, Dave Plater wrote:
>> The script with this header works on my local machine but fails in obs,
>> how can I find the python package that provides xml.etree.ElementTree :
>>
>> import xml.etree.ElementTree as etree
> if you have a machine where the necessary package is installed, you can
> do this:
>
> $ python2
>>>> import xml.etree.ElementTree
>>>> xml.etree.ElementTree.__file__
> '/usr/lib64/python2.7/xml/etree/ElementTree.pyc'
>
> ask rpm about this file and it will give you the right package.
>
> There is an alternate spelling of "import": "from A.B.C import D"
> In that case, you can't generally ask about D.__file__, so instead
> "import A.B.C" and ask about "A.B.C.__file__".
>
> I don't think there is a general tool to do this. It might be worth
> writing one for situations where you're looking for a package that you
> don't have installed. There's some work in Fedora that I'm looking to
> adopt, to automatically figure out pythonic dependencies.
>
> m.
>
>
That works for me, thanks, I need to derust my python and write a script
to use "rpm -q  --whatprovides" to provide the package name. Much easier
and quicker than the google method.
Thanks
Dave P
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How can I find the python package to satisfy a missing python script dependency?

Dave Plater lst
In reply to this post by Christian Boltz-5


On 09/01/2017 20:42, Christian Boltz wrote:

> Hello,
>
> Am Montag, 9. Januar 2017, 15:47:27 CET schrieb jan matejek:
>> On 9.1.2017 11:00, Dave Plater wrote:
>>> The script with this header works on my local machine but fails in
>>> obs, how can I find the python package that provides
>>> xml.etree.ElementTree :
>>>
>>> import xml.etree.ElementTree as etree
> ...
>> I don't think there is a general tool to do this. It might be worth
>> writing one for situations where you're looking for a package that you
>> don't have installed. There's some work in Fedora that I'm looking to
>> adopt, to automatically figure out pythonic dependencies.
> There is a very generic tool that might help - pin ;-)
>
> First, get ARCHIVES.gz for your openSUSE version, for example
> http://download.opensuse.org/distribution/leap/42.2/repo/oss/ARCHIVES.gz
> and save it in /var/lib/pin/
>
> Then run
>      pin 'xml.etree.ElementTree.*py'
> and pin will grep for that in ARCHIVES.gz.
>
> Note that the actual path actually contains xml/etree/ElementTree.py or
> xml/etree/ElementTree/__init__.py, which is why I proposed to use ".*py"
> and not just ".py". (Of course, you can search without the ".*py", but
> that might give you false positives.) Also, the dots are actually
> slashes, but a regex-dot matches any char which makes things a bit
> easier ;-)
>
>
> Regards,
>
> Christian Boltz
This is useful if the script fails on my local machine but Jan's method
works if it succeeds on my machine and fails in obs.
Thanks
Dave P
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]