[−][src]Struct pyembed::OxidizedPythonInterpreterConfig
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]
&mut self
) -> Result<&Option<Vec<PathBuf>>, &'static str>
Resolve the value to use for module search paths / sys.path.
Trait Implementations
impl<'a> Clone for OxidizedPythonInterpreterConfig<'a>
[src]
fn clone(&self) -> OxidizedPythonInterpreterConfig<'a>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a> Debug for OxidizedPythonInterpreterConfig<'a>
[src]
impl<'a> Default for OxidizedPythonInterpreterConfig<'a>
[src]
impl<'a> TryInto<PyConfig> for &'a OxidizedPythonInterpreterConfig<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for OxidizedPythonInterpreterConfig<'a>
impl<'a> Send for OxidizedPythonInterpreterConfig<'a>
impl<'a> Sync for OxidizedPythonInterpreterConfig<'a>
impl<'a> Unpin for OxidizedPythonInterpreterConfig<'a>
impl<'a> UnwindSafe for OxidizedPythonInterpreterConfig<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,