[Distutils] Buildout: How to include installed packages in sys.path?

Gustavo Narea gustavonarea at 2degreesnetwork.com
Mon Feb 15 12:04:21 CET 2010


Thank you, Jim. It worked!

 - Gustavo.

On 12/02/10 22:49, Jim Fulton wrote:
> On Fri, Feb 12, 2010 at 6:48 AM, Gustavo Narea
> <gustavonarea at 2degreesnetwork.com> wrote:
>   
>> Hello, Jim.
>>
>> Thank you very much for your response.
>>
>> I modified by recipe to use zc.recipe.egg like this:
>> ====
>> from zc.recipe.egg import Scripts
>> # ...
>> egg = Scripts(buildout, name, options)
>> egg.working_set((distribution_name,))
>> # ...
>> do_something_useful(distribution_name)
>> ====
>>
>> But still do_something_useful() is failing (distribution_name is not in
>> sys.path) and I think that's because I didn't use pkg_resources as you
>> suggested. I tried to do it, and read the documentation and source code
>> for pkg_resources, but I was not able to find the functionality I should
>> use.
>>     
>
> Change your call to working_set to capture the working set:
>
>   requirements, ws = egg.working_set((distribution_name,))
>
> Then:
>
>   for dist in ws:
>       pkg_resources.working_set.add(dist)
>
>
> Jim
>
> --
> Jim Fulton
>   

-- 
Gustavo Narea.
Software Developer.
2degrees, Ltd. <http://www.2degreesnetwork.com/>.



More information about the Distutils-SIG mailing list