Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
28cad964
Kaydet (Commit)
28cad964
authored
Agu 30, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Document newly revamped site configuration mechanism.
Damn the criticism in c.l.p!
üst
36764b8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
38 deletions
+126
-38
libsite.tex
Doc/lib/libsite.tex
+63
-19
libsite.tex
Doc/libsite.tex
+63
-19
No files found.
Doc/lib/libsite.tex
Dosyayı görüntüle @
28cad964
...
...
@@ -2,29 +2,73 @@
\label
{
module-site
}
\stmodindex
{
site
}
Scripts or modules that need to use site-specific modules should
execute
\code
{
import site
}
somewhere near the top of their code. This
will append up to two site-specific paths (
\code
{
sys.prefix +
'/lib/site-python'
}
and
\code
{
sys.exec
_
prefix + '/lib/site-python'
}
) to the module search path.
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are configured when Python is installed; the default value is
\file
{
/usr/local
}
.
Because of Python's import semantics, it is okay for more than one
module to import
\code
{
site
}
-- only the first one will execute the
site customizations. The directories are only appended to the path if
they exist and are not already on it.
Sites that wish to provide site-specific modules should place them in
one of the site specific directories;
\code
{
sys.prefix +
'/lib/site-python'
}
is for Python source code and
\code
{
sys.exec
_
prefix + '/lib/site-python'
}
is for dynamically
loadable extension modules (shared libraries).
\strong
{
This module is automatically imported during initialization.
}
In earlier versions of Python (up to and including 1.5a3), scripts or
modules that needed to use site-specific modules would place
\code
{
import site
}
somewhere near the top of their code. This is no
longer necessary.
This will append up site-specific paths to to the module search path.
It starts with
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
(if
different) and appends
\file
{
lib/python
\var
{
version
}
/packages
}
. The
resulting directory, if it exists, is added to
\code
{
sys.path
}
, and
also inspected for path configuration files. A path configuration
file is a file whose name has the form
\file
{
\var
{
package
}
.pth
}
; its
contents are additional directories (one per line) to be added to
\code
{
sys.path
}
. Non-existing directories (or non-directories) are
never added to
\code
{
sys.path
}
; no directory is added to
\code
{
sys.path
}
more than once. Blank lines and lines beginning with
\code
{
\#
}
are skipped.
\index
{
package
}
\kwindex
{
sys.prefix
}
\kwindex
{
sys.exec
_
prefix
}
\kwindex
{
prefix
}
\kwindex
{
exec
_
prefix
}
For example, suppose
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are
set to
\file
{
/usr/local
}
. The Python 1.5 library is then installed in
\file
{
/usr/local/lib/python1.5
}
. Suppose this has a subdirectory
\file
{
/usr/local/python1.5/packages
}
with three subsubdirectories,
\file
{
foo
}
,
\file
{
bar
}
and
\file
{
spam
}
, and two path configuration
files,
\file
{
foo.pth
}
and
\file
{
bar.pth
}
. Assume
\file
{
foo.pth
}
contains the following:
\bcode
\begin{verbatim}
# foo package configuration
foo
bar
bletch
\end{verbatim}
\ecode
and
\file
{
bar.pth
}
contains:
\bcode
\begin{verbatim}
# bar package configuration
bar
\end{verbatim}
\ecode
Then the following directories are added to sys.path, in this order:
\bcode
\begin{verbatim}
/usr/local/python1.5/packages/bar
/usr/local/python1.5/packages/foo
\end{verbatim}
\ecode
Note that
\file
{
bletch
}
is omitted because it doesn't exist; the
\file
{
bar
}
directory precedes the
\file
{
foo
}
directory because
\file
{
bar.pth
}
comes alphabetically before
\file
{
foo.pth
}
; and
\file
{
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
\code
{
sitecustomize
}
, which can perform arbitrary site-specific
customizations. If this import fails with an
\code
{
ImportError
}
exception, it is ignored.
exception, it is silently ignored.
\stmodindex
{
sitecustomize
}
Note that for non-Unix systems,
\code
{
sys.prefix
}
and
Note that for
some
non-Unix systems,
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are empty, and the path manipulations are
skipped; however the import of
\code
{
sitecustomize
}
is still attempted.
Doc/libsite.tex
Dosyayı görüntüle @
28cad964
...
...
@@ -2,29 +2,73 @@
\label
{
module-site
}
\stmodindex
{
site
}
Scripts or modules that need to use site-specific modules should
execute
\code
{
import site
}
somewhere near the top of their code. This
will append up to two site-specific paths (
\code
{
sys.prefix +
'/lib/site-python'
}
and
\code
{
sys.exec
_
prefix + '/lib/site-python'
}
) to the module search path.
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are configured when Python is installed; the default value is
\file
{
/usr/local
}
.
Because of Python's import semantics, it is okay for more than one
module to import
\code
{
site
}
-- only the first one will execute the
site customizations. The directories are only appended to the path if
they exist and are not already on it.
Sites that wish to provide site-specific modules should place them in
one of the site specific directories;
\code
{
sys.prefix +
'/lib/site-python'
}
is for Python source code and
\code
{
sys.exec
_
prefix + '/lib/site-python'
}
is for dynamically
loadable extension modules (shared libraries).
\strong
{
This module is automatically imported during initialization.
}
In earlier versions of Python (up to and including 1.5a3), scripts or
modules that needed to use site-specific modules would place
\code
{
import site
}
somewhere near the top of their code. This is no
longer necessary.
This will append up site-specific paths to to the module search path.
It starts with
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
(if
different) and appends
\file
{
lib/python
\var
{
version
}
/packages
}
. The
resulting directory, if it exists, is added to
\code
{
sys.path
}
, and
also inspected for path configuration files. A path configuration
file is a file whose name has the form
\file
{
\var
{
package
}
.pth
}
; its
contents are additional directories (one per line) to be added to
\code
{
sys.path
}
. Non-existing directories (or non-directories) are
never added to
\code
{
sys.path
}
; no directory is added to
\code
{
sys.path
}
more than once. Blank lines and lines beginning with
\code
{
\#
}
are skipped.
\index
{
package
}
\kwindex
{
sys.prefix
}
\kwindex
{
sys.exec
_
prefix
}
\kwindex
{
prefix
}
\kwindex
{
exec
_
prefix
}
For example, suppose
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are
set to
\file
{
/usr/local
}
. The Python 1.5 library is then installed in
\file
{
/usr/local/lib/python1.5
}
. Suppose this has a subdirectory
\file
{
/usr/local/python1.5/packages
}
with three subsubdirectories,
\file
{
foo
}
,
\file
{
bar
}
and
\file
{
spam
}
, and two path configuration
files,
\file
{
foo.pth
}
and
\file
{
bar.pth
}
. Assume
\file
{
foo.pth
}
contains the following:
\bcode
\begin{verbatim}
# foo package configuration
foo
bar
bletch
\end{verbatim}
\ecode
and
\file
{
bar.pth
}
contains:
\bcode
\begin{verbatim}
# bar package configuration
bar
\end{verbatim}
\ecode
Then the following directories are added to sys.path, in this order:
\bcode
\begin{verbatim}
/usr/local/python1.5/packages/bar
/usr/local/python1.5/packages/foo
\end{verbatim}
\ecode
Note that
\file
{
bletch
}
is omitted because it doesn't exist; the
\file
{
bar
}
directory precedes the
\file
{
foo
}
directory because
\file
{
bar.pth
}
comes alphabetically before
\file
{
foo.pth
}
; and
\file
{
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
\code
{
sitecustomize
}
, which can perform arbitrary site-specific
customizations. If this import fails with an
\code
{
ImportError
}
exception, it is ignored.
exception, it is silently ignored.
\stmodindex
{
sitecustomize
}
Note that for non-Unix systems,
\code
{
sys.prefix
}
and
Note that for
some
non-Unix systems,
\code
{
sys.prefix
}
and
\code
{
sys.exec
_
prefix
}
are empty, and the path manipulations are
skipped; however the import of
\code
{
sitecustomize
}
is still attempted.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment