Suppose, for just a moment, that you wish to ship Python
programs to an audience that may be in the very early stages of
evolving from computer user to computer programmer. Maybe you are
shipping a Python application to nontechnical users, or perhaps you're
interested in shipping a set of Python demo programs with a book.
Whatever the reason, some of the people who will use your software
can't be expected to do anything more than click a mouse. They
certainly won't be able to edit their system configuration files to
set things such as
PYTHONPATH per your programs'
assumptions. Your software will have to configure itself.
Luckily, Python scripts can do that too. In the next three sections, we're going to study three modules that aim to automatically launch programs with minimal assumptions about the environment on the host machine:
A library of tools for automatically configuring the shell
environment in preparation for launching a Python script. It can
be used to set required shell variables—both the
PATH system program search path (used
to find the "python" executable) and the
PYTHONPATH module search path (used to
resolve imports within scripts). Because such variable settings
made in a parent program are inherited by
spawned child programs, this interface lets scripts preconfigure
search paths for other scripts.
Aims to portably locate and start an Internet browser program on the host machine in order to view a local ...