OESF | ELSI | pdaXrom | OpenZaurus | Zaurus Themes | Community Links | Ibiblio

IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> 'adding' Modules To A Read Only Image, a simple trick
Optogeek
post Feb 16 2005, 09:13 AM
Post #1





Group: Members
Posts: 48
Joined: 3-February 04
From: Edinburgh, Scotland
Member No.: 1,681



This is probably obvious but I thought I should mention it.

If you are using kopsis' excellent read-only, compressed python image you can still add modules to the system even thought the site-packages directory is read-only.

Create a directory on you internal drive (I call mine /home/zaurus/python_mod) and then add to your .profile file the line

CODE
export PYTHONPATH=/home/zaurus/python_mod


You can now add modules to this directory as much as you want/have space for.

WARNING!!! This adds PYTHONPATH to the start of python's search path so if you add modules with the same name as in the image the new ones will be called first. This may or may not be a good thing wink.gif
Go to the top of the page
 
+Quote Post
Optogeek
post Mar 8 2005, 07:26 AM
Post #2





Group: Members
Posts: 48
Joined: 3-February 04
From: Edinburgh, Scotland
Member No.: 1,681



I know it is bad form to reply to your own posts but I have modifed this process slightly so that distutils can install new modules. This works with the READ ONLY image for modules that are pure python. If you what to install a module with bits of C in them you will need one of the dev images install but it should work.

Fist you need to add a couple of directories in your home directory if you don't already have them.

CODE
mkdir ~/bin
mkdir ~/lib
mkdir ~/lib/python
mkdir ~/share


Now add a line in your .profile file

CODE
PYTHONPATH=$HOME/lib/python
export PYTHONPATH


and optionally alter the PATH line

CODE
PATH={what ever is here}:$HOME/bin


Lastly create a file in your home directory called .pydistutils.cfg containing

CODE
[install]
home=$HOME


For good luck restart.

Now if you try to install something packaged with distutils you can use something like
CODE
python setup.py install


and the modules will be placed in the the ~/lib/python directory which is now sourced in your python code. In theory you can install newer/older versions of the modules in the read-only image and the freshly installed versions will override the built in versions (I have not tried this).

If anyone tries this let me know. I have installed a couple of packages with distutils and it seems to work ok as does writing modules and saving them into ~/lib/python
Go to the top of the page
 
+Quote Post
kopsis
post Mar 9 2005, 05:57 AM
Post #3





Group: Members
Posts: 329
Joined: 1-July 04
Member No.: 3,880



Great instructions! I need to remember to put a link to this post in the docs on my Sourceforge page smile.gif
Go to the top of the page
 
+Quote Post
Optogeek
post Mar 9 2005, 06:23 AM
Post #4





Group: Members
Posts: 48
Joined: 3-February 04
From: Edinburgh, Scotland
Member No.: 1,681



No problem.

I am still slowly learning how to use Python (upto Chapter 6 in Dive into Python) but I know my way around a *nix file system wink.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 31st October 2014 - 12:24 AM