[][src]Struct pyembed::OxidizedPythonInterpreterConfig

pub struct OxidizedPythonInterpreterConfig<'a> {
    pub origin: Option<PathBuf>,
    pub interpreter_config: PythonInterpreterConfig,
    pub raw_allocator: Option<PythonRawAllocator>,
    pub oxidized_importer: bool,
    pub filesystem_importer: bool,
    pub packed_resources: Option<&'a [u8]>,
    pub extra_extension_modules: Option<Vec<ExtensionModule>>,
    pub argvb: bool,
    pub sys_frozen: bool,
    pub sys_meipass: bool,
    pub terminfo_resolution: TerminfoResolution,
    pub write_modules_directory_env: Option<String>,
    pub run: PythonRunMode,
}

Configure a Python interpreter.

This type defines the configuration of a Python interpreter. It is used to initialize a Python interpreter embedded in the current process.

The type contains a reference to a PythonInterpreterConfig instance, which is an abstraction over the low-level C structs that Python uses during interpreter initialization.

The PythonInterpreterConfig has a single non-optional field: profile. This defines the defaults for various fields of the PyPreConfig and PyConfig instances that are initialized as part of interpreter initialization. See https://docs.python.org/3/c-api/init_config.html#isolated-configuration for more.

During interpreter initialization, we produce a PyPreConfig and PyConfig derived from this type. Config settings are applied in layers. First, we use the PythonInterpreterConfig.profile to derive a default instance given a profile. Next, we override fields if the PythonInterpreterConfig has Some(T) value set. Finally, we populate some fields if they are missing but required for the given configuration. For example, when in isolated mode, we set program_name and home unless an explicit value was provided in the PythonInterpreterConfig.

Generally speaking, the PythonInterpreterConfig exists to hold configuration that is defined in the CPython initialization and configuration API and OxidizedPythonInterpreterConfig exists to hold higher-level configuration for features specific to this crate.

Fields

origin: Option<PathBuf>

The filesystem path from which relative paths will be interpreted.

interpreter_config: PythonInterpreterConfig

Low-level configuration of Python interpreter.

raw_allocator: Option<PythonRawAllocator>

Allocator to use for Python's raw allocator.

oxidized_importer: bool

Whether to install our custom meta path importer on interpreter init.

filesystem_importer: bool

Whether to install the default PathFinder meta path finder.

packed_resources: Option<&'a [u8]>

Reference to packed resources data.

The referenced data contains Python module data. It likely comes from an include_bytes!(...) of a file generated by PyOxidizer.

The format of the data is defined by the python-packed-resources crate. The data will be parsed as part of initializing the custom meta path importer during interpreter initialization.

extra_extension_modules: Option<Vec<ExtensionModule>>

Extra extension modules to make available to the interpreter.

The values will effectively be passed to PyImport_ExtendInitTab().

argvb: bool

Whether to set sys.argvb with bytes versions of process arguments.

On Windows, bytes will be UTF-16. On POSIX, bytes will be raw char* values passed to int main().

sys_frozen: bool

Whether to set sys.frozen=True.

Setting this will enable Python to emulate "frozen" binaries, such as those used by PyInstaller.

sys_meipass: bool

Whether to set sys._MEIPASS to the directory of the executable.

Setting this will enable Python to emulate PyInstaller's behavior of setting this attribute.

terminfo_resolution: TerminfoResolution

How to resolve the terminfo database.

write_modules_directory_env: Option<String>

Environment variable holding the directory to write a loaded modules file.

If this value is set and the environment it refers to is set, on interpreter shutdown, we will write a modules-<random> file to the directory specified containing a \n delimited list of modules loaded in sys.modules.

run: PythonRunMode

Defines what code to run by default.

Implementations

impl<'a> OxidizedPythonInterpreterConfig<'a>[src]

pub fn ensure_origin(&mut self) -> Result<&Path, &'static str>[src]

pub fn resolve_module_search_paths(
    &mut self
) -> Result<&Option<Vec<PathBuf>>, &'static str>
[src]

Resolve the value to use for module search paths / sys.path.

Trait Implementations

impl<'a> Clone for OxidizedPythonInterpreterConfig<'a>[src]

impl<'a> Debug for OxidizedPythonInterpreterConfig<'a>[src]

impl<'a> Default for OxidizedPythonInterpreterConfig<'a>[src]

impl<'a> TryInto<PyConfig> for &'a OxidizedPythonInterpreterConfig<'a>[src]

type Error = String

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,