How to include and use .eggs/pkg_resources within a project directory targeting python 2.5.1
Asked Answered
C

2

3

I have python .egg files that are stored in a relative location to some .py code. The problem is, I am targeting python 2.5.1 computers which require my project be self contained in a folder (hundreds of thousands of OLPC XO 8.2.1 release laptops running Sugar). This means I cannot just ./ez_install to perform a system-wide setuptools/pkg_resources installation.

Example directory structure:

My Application/
My Application/library1.egg
My Application/libs/library2.egg
My Application/test.py

I am wondering how best to import and use library1 and library2 from within test.py with no pkg_resources system-wide installation. Is my best option simply to unzip the .egg files?

Thanks for any tips.

Croak answered 10/8, 2009 at 2:40 Comment(0)
U
1

If you want to be able to use pkg_resources, just copy pkg_resources.py alongside your application's main script. It's designed to be able to be used this way as a standalone runtime.

Unreasonable answered 24/5, 2010 at 16:14 Comment(0)
C
0

Include pkg_resources.py in the lib/ directory.

Add at the top of example.py...

   import sys
   sys.path.append("lib/")
   import pkg_resources

and then you can...

   sys.path.append("library1.egg")
   sys.path.append("libs/library2.egg")
   import library1
   import library2
Croak answered 10/8, 2009 at 3:1 Comment(1)
Put raw http copy of pkg_resources.py at shell.sugarlabs.org/~bjordan/pkg_resources.pyCroak

© 2022 - 2024 — McMap. All rights reserved.