pub struct PythonEnvironment {
pub python_path: String,
pub venv_path: Option<PathBuf>,
pub env_vars: HashMap<String, String>,
pub working_dir: Option<PathBuf>,
pub security: SecurityConfig,
}Expand description
Python environment configuration
Fields§
§python_path: StringPython interpreter path (default: “python3”)
venv_path: Option<PathBuf>Virtual environment path (optional)
env_vars: HashMap<String, String>Additional environment variables
working_dir: Option<PathBuf>Working directory for Python execution
security: SecurityConfigSecurity configuration
Implementations§
Source§impl PythonEnvironment
impl PythonEnvironment
Sourcepub fn with_env_var(self, key: String, value: String) -> Self
pub fn with_env_var(self, key: String, value: String) -> Self
Add environment variable
Sourcepub fn with_working_dir(self, dir: PathBuf) -> Self
pub fn with_working_dir(self, dir: PathBuf) -> Self
Set working directory
Sourcepub fn with_security(self, security: SecurityConfig) -> Self
pub fn with_security(self, security: SecurityConfig) -> Self
Set security configuration
Sourcepub async fn check_availability(&self) -> Result<bool>
pub async fn check_availability(&self) -> Result<bool>
Check if Python is available
Sourcepub async fn run_script(
&self,
script_path: &Path,
args: &[&str],
) -> Result<String>
pub async fn run_script( &self, script_path: &Path, args: &[&str], ) -> Result<String>
Run a Python script and return output
Sourcepub async fn run_code(&self, code: &str) -> Result<String>
pub async fn run_code(&self, code: &str) -> Result<String>
Run Python code directly
§Security Warning
This method is dangerous and should only be used with trusted code.
By default, allow_direct_code is false in SecurityConfig.
Sourcepub async fn check_package(&self, package: &str) -> Result<bool>
pub async fn check_package(&self, package: &str) -> Result<bool>
Check if a Python package is installed
Trait Implementations§
Source§impl Clone for PythonEnvironment
impl Clone for PythonEnvironment
Source§fn clone(&self) -> PythonEnvironment
fn clone(&self) -> PythonEnvironment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PythonEnvironment
impl Debug for PythonEnvironment
Source§impl Default for PythonEnvironment
impl Default for PythonEnvironment
Source§impl<'de> Deserialize<'de> for PythonEnvironment
impl<'de> Deserialize<'de> for PythonEnvironment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PythonEnvironment
impl RefUnwindSafe for PythonEnvironment
impl Send for PythonEnvironment
impl Sync for PythonEnvironment
impl Unpin for PythonEnvironment
impl UnwindSafe for PythonEnvironment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more