Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/site.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@sdZddkZddkZddkZd�Zd�Zd�Zd�Zd�Zd�Z	dd	�Zd
�Zd�Z
d�Zd
efd��YZd�Zdefd��YZd�Zd�Zd�Zd�Zd�Ze�d�Zedjoe�ndS(sN	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 (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
lib/python<version>/site-packages as well as lib/site-python.
On other platforms (such as Windows), it tries each of the
prefixes directly, as well as with lib/site-packages appended.  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

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.5/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.5/site-packages/bar
  /usr/local/lib/python2.5/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.

i�NcGs4tiitii|��}|tii|�fS(N(tostpathtabspathtjointnormcase(tpathstdir((s/sys/lib/python/site.pytmakepathBscCsjxctii�D]R}t|d�oqnytii|i�|_Wqtj
o
qqXqWdS(s6Set all module' __file__ attribute to an absolute patht
__loader__N(	tsystmodulestvaluesthasattrRRRt__file__tAttributeError(tm((s/sys/lib/python/site.pytabs__file__FscCsng}t�}xNtiD]C}t|�\}}||jo|i|�|i|�qqW|ti(|S(sK Remove duplicate entries from sys.path along with making them
    absolute(tsetR	RRtappendtadd(tLtknown_pathsRtdircase((s/sys/lib/python/site.pytremoveduppathsPs	



cCsbddkl}d|�tif}tiitiitid�|�}tii|�dS(sbAppend ./build/lib.<platform> in case we're running in the build dir
    (especially for Guido :-)i�(tget_platformsbuild/lib.%s-%.3sN(	tdistutils.utilRR	tversionRRRtdirnameR(Rts((s/sys/lib/python/site.pytaddbuilddirds(cCstt�}xdtiD]Y}y:tii|�o#t|�\}}|i|�nWqtj
o
qqXqW|S(sDReturn a set containing all existing directory entries from sys.path(RR	RRtisdirRRt	TypeError(tdRR((s/sys/lib/python/site.pyt_init_pathinfols	
c	
Bs6|djoe�d}nd}eii||�}ye|d�}Wnej
odSnXz�x�|D]�}|id�oqpn|id�o|dUqpn|i�}e	||�\}}||jo4eii
|�o!eii|�|i
|�qpqpWWd|i�X|o
d}n|S(soAdd a new path to known_paths by combining sitedir and 'name' or execute
    sitedir if it starts with 'import'iitrUNt#timport(tNoneR!RRRtopentIOErrort
startswithtrstripRtexistsR	RRtclose(	tsitedirtnameRtresettfullnametftlineRR((s/sys/lib/python/site.pyt
addpackagexs4

	 
cCs�|djot�}d}nd}t|�\}}||jotii|�nyti|�}Wntij
odSnX|i	�x9|D]1}|i
tid�ot|||�q�q�W|o
d}n|S(sTAdd 'sitedir' argument to sys.path if missing and handle .pth files in
    'sitedir'iiNtpth(
R%R!RR	RRRtlistdirterrortsorttendswithtextsepR2(R,RR.tsitedircasetnamesR-((s/sys/lib/python/site.pyt
addsitedir�s&
	

	

c
Cs�tig}titijo|iti�nx[|D]S}|oFtidjotii|dd�g}nqtidjoBtii|ddti	d d�tii|dd	�g}n|tii|dd�g}tid
jo^d|joMti
id�}|o0|itii|d
dti	d d��qPqTnx6|D]*}tii|�ot
||�q[q[Wq:q:WdS(s8Add site-packages (and possibly site-python) to sys.pathtos2emxtriscostLibs
site-packagest/tlibtpythonissite-pythontdarwinsPython.frameworktHOMEtLibrarytPython(R<R=N(R	tprefixtexec_prefixRtplatformRRRtsepRtenvirontgetRR;R%(RtprefixesRFtsitedirsthomeR,((s/sys/lib/python/site.pytaddsitepackages�s<

cCsqtiitidd�}tidid�}|do|i|�n||d<di|�tid<dS(sEThe 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.

    R>slib-dynloadtBEGINLIBPATHt;i�N(RRRR	RFRJtsplitR(tdllpathtlibpath((s/sys/lib/python/site.pytsetBEGINLIBPATH�s
csxtidjo
d�n!tidjo
d�nd�dtf�fd��Y}|d�t_|d	�t_d
S(snDefine new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.

    t:sCmd-Qs\sCtrl-Z plus ReturnsCtrl-D (i.e. EOF)tQuittercs,eZd�Z�fd�Zdd�ZRS(cSs
||_dS(N(R-(tselfR-((s/sys/lib/python/site.pyt__init__�scsd|i�fS(NsUse %s() or %s to exit(R-(RX(teof(s/sys/lib/python/site.pyt__repr__�scSs+ytii�WnnXt|��dS(N(R	tstdinR+t
SystemExit(RXtcode((s/sys/lib/python/site.pyt__call__�s
N(t__name__t
__module__RYR[R%R_((RZ(s/sys/lib/python/site.pyRW�s	tquittexitN(RRItobjectt__builtin__RbRc(RW((RZs/sys/lib/python/site.pytsetquit�s


t_PrintercBs>eZdZdZddd�Zd�Zd�Zd�ZRS(sninteractive prompt objects for printing the license text, a list of
    contributors and the copyright notice.icCs1||_||_||_||_d|_dS(N(t_Printer__namet_Printer__datat_Printer__filest_Printer__dirsR%t_Printer__lines(RXR-tdatatfilestdirs((s/sys/lib/python/site.pyRYs
				cCs�|iodSnd}x�|iD]{}xf|iD][}tii||�}y*t|d�}|i�}|i	�PWq2t
j
oq2Xq2W|oPq"q"W|p
|i}n|id�|_t
|i�|_dS(NR"s
(RlR%RkRjRRRtfiletreadR+R'RiRRtlent_Printer__linecnt(RXRmRtfilenametfp((s/sys/lib/python/site.pyt__setup
s*



		
cCsM|i�t|i�|ijodi|i�Snd|ifdSdS(Ns
s!Type %s() to see the full %s texti(t_Printer__setupRrRltMAXLINESRRh(RX((s/sys/lib/python/site.pyR["s
cCs�|i�d}d}x�y1x*t|||i�D]}|i|GHq3WWntj
oPqX||i7}d}x5|djo't|�}|djo
d}qwqwW|djoPqqdS(Ns0Hit Return for more, or q (and Return) to quit: ittq(RyRz(RwtrangeRxRlt
IndexErrorR%t	raw_input(RXtprompttlinenotitkey((s/sys/lib/python/site.pyR_)s$



(((R`Rat__doc__RxRYRwR[R_(((s/sys/lib/python/site.pyRgs		cCs�tdti�t_tid djotdd�t_ntdd�t_tiiti	�}tddti
d	d
gtii|ti�|ti
g�t_dS(s,Set 'copyright' and 'credits' in __builtin__t	copyrightitjavatcreditss?Jython is maintained by the Jython developers (www.jython.org).s�    Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information.tlicenses+See http://www.python.org/%.3s/license.htmlsLICENSE.txttLICENSEN(RgR	R�ReRHR�RRRR
RRtpardirtcurdirR�(there((s/sys/lib/python/site.pytsetcopyright=s
	t_HelpercBs eZdZd�Zd�ZRS(sYDefine the built-in 'help'.
    This is a wrapper around pydoc.help (with a twist).

    cCsdS(NsHType help() for interactive help, or help(object) for help about object.((RX((s/sys/lib/python/site.pyR[UscOsddk}|i||�S(Ni�(tpydocthelp(RXtargstkwdsR�((s/sys/lib/python/site.pyR_Xs(R`RaR�R[R_(((s/sys/lib/python/site.pyR�Os	cCst�t_dS(N(R�ReR�(((s/sys/lib/python/site.pyt	sethelper\scCs�tidjo�ddk}ddk}|i�d}|id�oWy|i|�Wq�tj
o3ddk}|i	|i
|<d|ii|<q�Xq�ndS(s�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.twin32i�Nitcptmbcs(R	RHtlocaletcodecstgetdefaultlocaleR(tlookuptLookupErrort	encodingst_unknownt_cachetaliases(R�R�tencR�((s/sys/lib/python/site.pyt	aliasmbcs_scCs(d}|djoti|�ndS(s�Set the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this.tasciiN(R	tsetdefaultencoding(tencoding((s/sys/lib/python/site.pytsetencodingns
cCs*yddk}Wntj
onXdS(s,Run custom site specific code, if available.i�N(t
sitecustomizetImportError(R�((s/sys/lib/python/site.pytexecsitecustomize�scCs�t�t�}tidjo5tio+tiitid�djot�nt|�}ti	djot
�nt�t�t
�t�t�t�ttd�o
t`ndS(Ntposixi�tModulesR<R�(RRRR-R	RtbasenameRRORHRURfR�R�R�R�R�RR�(tpaths_in_sys((s/sys/lib/python/site.pytmain�s 	 cCs.dGHxtiD]}d|fGHqWdGHdS(Nssys.path = [s    %r,t](R	R(R((s/sys/lib/python/site.pyt_test�s

t__main__(R�R	RReRRRRR!R2R%R;RORURfRdRgR�R�R�R�R�R�R�R�R`(((s/sys/lib/python/site.pys<module>;s2		
					$		=	
						


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.