I wrote a quick script to add the dir's to the .pydevproject file but
I have the same problem after a Project -> Clean ... even though all
the src/* and packages/* directories show up in the PyDev -
PYTHONPATH.


#!/usr/bin/env python
import sys
import os
from shutil import copyfile

from xml.etree.ElementTree import Element, ElementTree, tostring

pth_file = sys.argv[1]
pydevproject_file = sys.argv[2]
prefix = sys.argv[3]

copyfile(pydevproject_file, pydevproject_file+'.bak')

tree = ElementTree()
tree.parse(pydevproject_file)
pydev_pathproperty = tree.find("pydev_pathproperty")
paths = pydev_pathproperty.getiterator('path')

with open(pth_file) as f:
    for line in f:
        pydev_entry = prefix + line.rstrip()
        if pydev_entry in paths:
            pass
        else:
            pydev_element = Element('path')
            pydev_element.text = pydev_entry
            pydev_pathproperty.append(pydev_element)

tree.write(pydevproject_file)



On Mon, Feb 21, 2011 at 11:32 AM, Luke Crouch <luke.cro...@gmail.com> wrote:
> I can write a script to read the .pth file and add all lines to
> .pydevproject's pydev_pathproperty, but I think this would be a great
> feature to add in PyDev itself - "Add .pth file" in addition to "Add
> source folder", "Add zip/jar/egg" and "Add based on variable"
>
> -L
>
> On Sat, Feb 19, 2011 at 9:23 AM, Fabio Zadrozny <fabi...@gmail.com> wrote:
>> On Fri, Feb 18, 2011 at 6:17 PM, Luke Crouch <luke.cro...@gmail.com> wrote:
>>> I have a pydev project named 'kuma' with a vendor/kuma.pth file like so:
>>>
>>> packages
>>> packages/pytz
>>> packages/coverage
>>> ...
>>> src
>>> src/django-cronjobs
>>> src/django-cache-machine
>>>
>>> I tried adding vendor/ to the project PYTHONPATH, but it doesn't add
>>> the directories from the .pth file? E.g.,
>>>
>>> from caching.base import cache
>>>
>>> gives 'Unresolved import: cache' even though
>>> src/django-cache-machine/caching/base.py defines it
>>>
>>> I've got 59 lib's in my kuma.pth file - I'd rather not have to add
>>> each of them to the PyDev - PYTHONPATH. So how can I add .pth files
>>> and/or their contents to PyDev - PYTHONPATH?
>>
>> .pth files aren't really used (or interpreted) in pydev. If you have
>> defined them in the interpreter, when adding the interpreter, all
>> those paths should be presented, now, if you only want to add them to
>> a project, as there are really lots of files, a solution would be
>> editing the .pydevproject file directly (it's a raw xml file -- you
>> can add only one of those paths to see how it's added, open it in the
>> text editor and use the Eclipse rectangular edit (ctrl+shift+A) so
>> that you can just copy all those contents in a single step, or you
>> could create a script that gets the original file and creates the
>> .pydevproject accordingly -- which may be better if you're always
>> updating that file).
>>
>> Cheers,
>>
>> Fabio
>>
>

------------------------------------------------------------------------------
Index, Search & Analyze Logs and other IT data in Real-Time with Splunk 
Collect, index and harness all the fast moving IT data generated by your 
applications, servers and devices whether physical, virtual or in the cloud.
Deliver compliance at lower cost and gain new business insights. 
Free Software Download: http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to