Voidspace

Movable Python: The Portable Python Distribution

The Special Files

Controlling and Customising Movable Python

Python on a Stick

Introduction

Some of the behavior of Movable Python is controlled by a few files in the lib directory.

You can configure :

  1. The environment programs run in: customize.py
  2. Paths to add to sys.path: syspaths.pth
  3. Various config files: stored in lib/config/
  4. The lib/config/logs/ directory.
  5. Your IPython config options: ipythonrc.ini

These files all use simple text based formats; they can be edited with any text editor.

Some of these can be changed by the GUI, and are probably better not edited by hand. See the individual sections for details.

Note

The GUI can only save changes if it has write permission in the lib directory.

That means you can't save changes if your distribution is on a CD.

customize.py

This Python script is run (rather than imported) before every program is run. This means you can edit it to customise the environment your scripts run in.

It is also run before entering interactive mode. (- at the command line, or the interpreter launched from the GUI.)

There is a module called movpy which you can import to give you access to information about the environment the interpreter is running.

Note

Note the spelling of the filename customize.py.

Sorry for the inconsistentency in my spelling. Surprised

The movpy module defines the following names.

  • filename : the path to the script we are running

  • filedir : the directory that script is in

  • movpydir : the directory of the movpy executable

  • curdir : the cwd from which we have been called

  • libdir : the 'lib' directory that modules/packages are contained in

  • commandline : not equals to '' if '-c' was used at the command line

  • go_interactive : True if '-i' was set.

  • interactive : True if we are in an interactive session

  • interactive_mode : is a function to enter interactive mode

    interactive_mode(localvars=None, globalvars=None, IPOFF=False, argv=None)

  • movpyw : True if we are running under movpyw rather than movpy

syspaths.pth

This file lets you specify directories to add to the module search path (sys.path).

If paths are specified as relative locations, they should be relative to the 'lib/' directory in which the path file lives.

If you manually add a module into your lib directory that normally has a '.pth' file [1], then you will need to make an entry here.

This includes modules like 'wx', 'pyGTK', 'PIL', etc. (Note that win32 has particular complications. Read the instructions at win32ext).

Copying the contents of the '.pth' file into syspaths.pth will usually be sufficient.

Note

.pth files can contain import statements. This isn't supported by Movable Python.

Config Files

The lib/config/ directory contains various config files used by Movable Python.

These include :

  • config.txt : The options saved by Movable Python. These can be set from the GUI and are always used by Movable Python unless you pass in the -o (override) command line option.
  • file_history.txt : The history of files you have launched from the GUI.
  • ide.txt : The IDE launched by the IDE button.
  • initial_directory.txt : The initial directory for the file open dialog.
  • logging.txt : Your logging settings.
  • quicklaunch.txt : The settings for your Quick Launch buttons.

The Logs Directory

The directory lib/config/logs/ is the default location for files created by Movable Python logging.

ipythonrc.ini

This file is your configuration file for IPython. IPython is very powerful and flexible. See the manual in the 'manuals' directory for details on how to configure and use IPython to its best.


Footnotes

[1].pth files normally live in the site-packages folder, so it should be easy to see if a package has a .pth file.
[2]If you mess it up you will lose your settings. You have been warned. Cool

Return to Top
Part of the Movable Python Docs
Page last modified Wed Jul 16 02:31:30 2008.

Download Movable Python

Powered by Python

Site Built with rest2web

Hosting for an agile web


Site Built with rest2web

Python on Voidspace