[−][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
exe: Option<PathBuf>The path of the currently executing executable.
origin: Option<PathBuf>The filesystem path from which relative paths will be interpreted.
interpreter_config: PythonInterpreterConfigLow-level configuration of Python interpreter.
raw_allocator: Option<PythonRawAllocator>Allocator to use for Python's raw allocator.
set_missing_path_configuration: boolWhether to automatically set missing "path configuration" fields.
If true, various path configuration
(https://docs.python.org/3/c-api/init_config.html#path-configuration) fields
will be set automatically if their corresponding .interpreter_config
fields are None. For example, program_name will be set to the current
executable and home will be set to the executable's directory.
If this is false, the default path configuration built into libpython
is used.
Setting this to false likely enables isolated interpreters to be used
with "external" Python installs. If this is true, the default isolated
configuration expects files like the Python standard library to be installed
relative to the current executable. You will need to either ensure these
files are present, define packed_resources, and/or set
.interpreter_config.module_search_paths to ensure the interpreter can find
the Python standard library, otherwise the interpreter will fail to start.
Without this set or corresponding .interpreter_config fields set, you
may also get run-time errors like
Could not find platform independent libraries <prefix> or
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]. If you see
these errors, it means the automatic path config resolutions built into
libpython didn't work because the run-time layout didn't match the
build-time configuration.
oxidized_importer: boolWhether to install our custom meta path importer on interpreter init.
filesystem_importer: boolWhether to install the default PathFinder meta path finder.
packed_resources: Vec<&'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().
argv: Option<Vec<OsString>>Command line arguments to initialize sys.argv with.
If Some(T), interpreter initialization will set PyConfig.argv
to a value derived from this value, overwriting an existing
.interpreter_config.argv value, if set.
None is evaluated to Some(std::env::args_os().collect::<Vec<_>>()
if .interpreter_config.argv is None or None if
.interpreter_config.argv is Some(T).
argvb: boolWhether 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: boolWhether to set sys.frozen=True.
Setting this will enable Python to emulate "frozen" binaries, such as those used by PyInstaller.
sys_meipass: boolWhether 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: TerminfoResolutionHow to resolve the terminfo database.
tcl_library: Option<PathBuf>Path to use to define the TCL_LIBRARY environment variable.
This directory should contain an init.tcl file. It is commonly
a directory named tclX.Y. e.g. tcl8.6.
$ORIGIN in the path is expanded to the directory of the current
executable.
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.
Implementations
impl<'a> OxidizedPythonInterpreterConfig<'a>[src]
pub fn resolve(
self
) -> Result<ResolvedOxidizedPythonInterpreterConfig<'a>, &'static str>[src]
self
) -> Result<ResolvedOxidizedPythonInterpreterConfig<'a>, &'static str>
Create a new type with all values resolved.
pub fn resolve_sys_argv(&self) -> Option<Vec<OsString>>[src]
Resolve OsString to use for sys.argv.
Returns Some(T) if we should populate PyConfig.argv or None if we should
leave this value alone.
pub fn resolve_sys_argvb(&self) -> Vec<OsString>[src]
Resolve the value to use for sys.argvb.
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]
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>,