portage package


Module contents

class portage._ForkWatcher

Bases: object

current_pid = None
static hook(_ForkWatcher)
class portage._LegacyGlobalProxy(name)

Bases: portage.proxy.objectproxy.ObjectProxy


This deletes the ObjectProxy instances that are used for lazy initialization of legacy global variables. The purpose of deleting them is to prevent new code from referencing these deprecated variables.

class portage._eintr_func_wrapper(func)

Bases: object

Wraps a function and handles EINTR by calling the function as many times as necessary (until it returns without raising EINTR).


Buggy code in python’s multiprocessing/process.py closes sys.stdin and reassigns it to open(os.devnull), but fails to update the corresponding __stdin__ reference. So, detect that case and handle it appropriately.

portage._movefile(src, dest, **kwargs)

Calls movefile and raises a PortageException if an error occurs.

portage._native_string(s, encoding='utf_8', errors='replace')

Quote a string in double-quotes and use backslashes to escape any backslashes, double-quotes, dollar signs, or backquotes in the string.

class portage._trees_dict(*pargs, **kargs)

Bases: dict

clear() → None. Remove all items from D.
copy() → a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() → a set-like object providing a view on D’s items
keys() → a set-like object providing a view on D’s keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, default is returned if given, otherwise KeyError is raised


Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → an object providing a view on D’s values
portage._unicode_decode(s, encoding='utf_8', errors='replace')
portage._unicode_encode(s, encoding='utf_8', errors='backslashreplace')
class portage._unicode_func_wrapper(func, encoding='utf_8')

Bases: object

Wraps a function, converts arguments from unicode to bytes, and return values to unicode from bytes. Function calls will raise UnicodeEncodeError if an argument fails to be encoded with the required encoding. Return values that are single strings are decoded with errors=’replace’. Return values that are lists of strings are decoded with errors=’strict’ and elements that fail to be decoded are omitted from the returned list.

_process_args(args, kwargs)
class portage._unicode_module_wrapper(mod, encoding='utf_8', overrides=None, cache=True)

Bases: object

Wraps a module and wraps all functions with _unicode_func_wrapper.


This reads symlinks, resolving the relative symlinks, and returning the absolute. :param symlink: path of symlink (must be absolute) :param target: the target of the symlink (as returned

by readlink)

Return type



the absolute path of the symlink target

portage.create_trees(config_root=None, target_root=None, trees=None, env=None, sysroot=None, eprefix=None)

this fixes situations where the current directory doesn’t exist


Cached version of os.getpid(). ForkProcess updates the cache.