Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a80a3e

Browse files
committed
Added docs for (draft) pkgutil module.
1 parent 633d90c commit 4a80a3e

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

Doc/Makefile.deps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \
120120
lib/libmarshal.tex \
121121
lib/libwarnings.tex \
122122
lib/libimp.tex \
123+
lib/libpkgutil.tex \
123124
lib/libparser.tex \
124125
lib/libbltin.tex \
125126
lib/libmain.tex \

Doc/lib/lib.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ \chapter*{Front Matter\label{front}}
9090
\input{libmarshal}
9191
\input{libwarnings}
9292
\input{libimp}
93+
\input{libpkgutil}
9394
\input{libcode}
9495
\input{libcodeop}
9596
\input{libpprint}

Doc/lib/libpkgutil.tex

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
\section{\module{pkgutil} ---
2+
Package extension utility}
3+
4+
\declaremodule{standard}{pkgutil}
5+
\modulesynopsis{Utilities to support extension of packages.}
6+
7+
\versionadded{2.3}
8+
9+
\begin{notice}[warning]
10+
This is an experimental module. It may be withdrawn or completely
11+
changed up to an including the release of Python 2.3 beta 1.
12+
\end{notice}
13+
14+
This module provides a single function:
15+
16+
\begin{funcdesc}{extend_path}{path, name}
17+
Extend the search path for the modules which comprise a package.
18+
Intended use is to place the following code in a package's
19+
\file{__init__.py}:
20+
21+
\begin{verbatim}
22+
from pkgutil import extend_path
23+
__path__ = extend_path(__path__, __name__)
24+
\end{verbatim}
25+
26+
This will add to the package's \code{__path__} all subdirectories of
27+
directories on \code{sys.path} named after the package. This is
28+
useful if one wants to distribute different parts of a single
29+
logical package as multiple directories.
30+
31+
It also looks for \file{*.pkg} files beginning where \code{*}
32+
matches the \var{name} argument. This feature is similar to
33+
\file{*.pth} files (see the \refmodule{site} module for more
34+
information), except that it doesn't special-case lines starting
35+
with \code{import}. A \file{*.pkg} file is trusted at face value:
36+
apart from checking for duplicates, all entries found in a
37+
\file{*.pkg} file are added to the path, regardless of whether they
38+
exist the filesystem. (This is a feature.)
39+
40+
If the input path is not a list (as is the case for frozen
41+
packages) it is returned unchanged. The input path is not
42+
modified; an extended copy is returned. Items are only appended
43+
to the copy at the end.
44+
45+
It is assumed that \code{sys.path} is a sequence. Items of
46+
\code{sys.path} that are not (Unicode or 8-bit) strings referring to
47+
existing directories are ignored. Unicode items on \code{sys.path}
48+
that cause errors when used as filenames may cause this function to
49+
raise an exception (in line with \function{os.path.isdir()} behavior).
50+
\end{funcdesc}

0 commit comments

Comments
 (0)