Orbits  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
Classes | Functions | Variables
site Namespace Reference

Classes

class  _Printer
 
class  _Helper
 

Functions

def makepath
 
def abs__file__
 
def removeduppaths
 
def addbuilddir
 
def _init_pathinfo
 
def addpackage
 
def addsitedir
 
def addsitepackages
 
def check_enableusersite
 
def addusersitepackages
 
def setBEGINLIBPATH
 
def setquit
 
def setcopyright
 
def sethelper
 
def aliasmbcs
 
def setencoding
 
def execsitecustomize
 
def virtual_install_main_packages
 
def force_global_eggs_after_local_site_packages
 
def virtual_addsitepackages
 
def fixclasspath
 
def execusercustomize
 
def main
 
def _script
 

Variables

list PREFIXES = [sys.prefix, sys.exec_prefix]
 
 ENABLE_USER_SITE = None
 
 USER_SITE = None
 
 USER_BASE = None
 
tuple _is_64bit = (getattr(sys, 'maxsize', None) or getattr(sys, 'maxint'))
 
tuple _is_pypy = hasattr(sys, 'pypy_version_info')
 
list _is_jython = sys.platform[:4]
 
tuple ModuleType = type(os)
 
 name
 

Detailed Description

Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
appends lib/python<version>/site-packages as well as lib/site-python.
It also supports the Debian convention of
lib/python<version>/dist-packages.  On other platforms (mainly Mac and
Windows), it uses just sys.prefix (and sys.exec_prefix, if different,
but this is unlikely).  The resulting directories, if they exist, are
appended to sys.path, and also inspected for path configuration files.

FOR DEBIAN, this sys.path is augmented with directories in /usr/local.
Local addons go into /usr/local/lib/python<version>/site-packages
(resp. /usr/local/lib/site-python), Debian addons install into
/usr/{lib,share}/python<version>/dist-packages.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory /usr/local/lib/python2.X/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python2.X/site-packages/bar
  /usr/local/lib/python2.X/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes foo
because bar.pth comes alphabetically before foo.pth; and spam is
omitted because it is not mentioned in either path configuration file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Function Documentation

def site._init_pathinfo ( )
private
Return a set containing all existing directory entries from sys.path
def site._script ( )
private
def site.abs__file__ ( )
Set all module' __file__ attribute to an absolute path
def site.addbuilddir ( )
Append ./build/lib.<platform> in case we're running in the build dir
(especially for Guido :-)
def site.addpackage (   sitedir,
  name,
  known_paths 
)
Add a new path to known_paths by combining sitedir and 'name' or execute
sitedir if it starts with 'import'
def site.addsitedir (   sitedir,
  known_paths = None 
)
Add 'sitedir' argument to sys.path if missing and handle .pth files in
'sitedir'
def site.addsitepackages (   known_paths,
  sys_prefix = sys.prefix,
  exec_prefix = sys.exec_prefix 
)
Add site-packages (and possibly site-python) to sys.path
def site.addusersitepackages (   known_paths)
Add a per user site-package to sys.path

Each user has its own python directory with site-packages in the
home directory.

USER_BASE is the root directory for all Python versions

USER_SITE is the user specific site-packages directory

USER_SITE/.. can be used for data.
def site.aliasmbcs ( )
On Windows, some default encodings are not provided by Python,
while they are always available as "mbcs" in each locale. Make
them usable by aliasing to "mbcs" in such a case.
def site.check_enableusersite ( )
Check if user site directory is safe for inclusion

The function tests for the command line flag (including environment var),
process uid/gid equal to effective uid/gid.

None: Disabled for security reasons
False: Disabled by user (command line option)
True: Safe and enabled
def site.execsitecustomize ( )
Run custom site specific code, if available.
def site.execusercustomize ( )
Run custom user specific code, if available.
def site.fixclasspath ( )
Adjust the special classpath sys.path entries for Jython. These
entries should follow the base virtualenv lib directories.
def site.force_global_eggs_after_local_site_packages ( )
Force easy_installed eggs in the global environment to get placed
in sys.path after all packages inside the virtualenv.  This
maintains the "least surprise" result that packages in the
virtualenv always mask global packages, never the other way
around.
def site.main ( )
def site.makepath (   paths)
def site.removeduppaths ( )
Remove duplicate entries from sys.path along with making them
absolute
def site.setBEGINLIBPATH ( )
The OS/2 EMX port has optional extension modules that do double duty
as DLLs (and must use the .DLL file extension) for other extensions.
The library search path needs to be amended so these will be found
during module import.  Use BEGINLIBPATH so that these are at the start
of the library search path.
def site.setcopyright ( )
Set 'copyright' and 'credits' in __builtin__
def site.setencoding ( )
Set the string encoding used by the Unicode implementation.  The
default is 'ascii', but if you're willing to experiment, you can
change this.
def site.sethelper ( )
def site.setquit ( )
Define new built-ins 'quit' and 'exit'.
These are simply strings that display a hint on how to exit.
def site.virtual_addsitepackages (   known_paths)
def site.virtual_install_main_packages ( )

Variable Documentation

tuple site._is_64bit = (getattr(sys, 'maxsize', None) or getattr(sys, 'maxint'))
list site._is_jython = sys.platform[:4]
tuple site._is_pypy = hasattr(sys, 'pypy_version_info')
site.ENABLE_USER_SITE = None
tuple site.ModuleType = type(os)
site.name
list site.PREFIXES = [sys.prefix, sys.exec_prefix]
site.USER_BASE = None
site.USER_SITE = None

Copyright 2014 Google Inc. All rights reserved.