Author Topic: 'adding' Modules To A Read Only Image  (Read 5823 times)

Optogeek

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://optogeek.homelinux.net
'adding' Modules To A Read Only Image
« on: February 16, 2005, 12:13:01 pm »
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: [Select]
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
SL-C860 running Cacko 1.23
SL-5500UK with 3.13 Sharp ROM + Cacko Kernel
Origo WLAN and BlueMonkey BT CFs
1GB Crucial SD
1GB Crucial CF

Optogeek

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://optogeek.homelinux.net
'adding' Modules To A Read Only Image
« Reply #1 on: March 08, 2005, 10:26:38 am »
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: [Select]
mkdir ~/bin
mkdir ~/lib
mkdir ~/lib/python
mkdir ~/share

Now add a line in your .profile file

Code: [Select]
PYTHONPATH=$HOME/lib/python
export PYTHONPATH

and optionally alter the PATH line

Code: [Select]
PATH={what ever is here}:$HOME/bin
Lastly create a file in your home directory called .pydistutils.cfg containing

Code: [Select]
[install]
home=$HOME

For good luck restart.

Now if you try to install something packaged with distutils you can use something like
Code: [Select]
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
« Last Edit: March 08, 2005, 01:09:03 pm by Optogeek »
SL-C860 running Cacko 1.23
SL-5500UK with 3.13 Sharp ROM + Cacko Kernel
Origo WLAN and BlueMonkey BT CFs
1GB Crucial SD
1GB Crucial CF

kopsis

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • http://kopsisengineering.com
'adding' Modules To A Read Only Image
« Reply #2 on: March 09, 2005, 08:57:33 am »
Great instructions! I need to remember to put a link to this post in the docs on my Sourceforge page

Optogeek

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • http://optogeek.homelinux.net
'adding' Modules To A Read Only Image
« Reply #3 on: March 09, 2005, 09:23:03 am »
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
SL-C860 running Cacko 1.23
SL-5500UK with 3.13 Sharp ROM + Cacko Kernel
Origo WLAN and BlueMonkey BT CFs
1GB Crucial SD
1GB Crucial CF