pub struct PyEnv { /* private fields */ }
Expand description
A Python environment that can install packages and execute code.
Implementations§
source§impl PyEnv
impl PyEnv
sourcepub fn new(
path: impl Into<PathBuf>,
std_out: impl Fn(&str) + 'static,
std_err: impl Fn(&str) + 'static
) -> Self
pub fn new( path: impl Into<PathBuf>, std_out: impl Fn(&str) + 'static, std_err: impl Fn(&str) + 'static ) -> Self
Constructor for piping stdout and stderr to a custom stream.
Use at()
if you want to inherit the streams.
sourcepub fn at(path: impl Into<PathBuf>) -> Self
pub fn at(path: impl Into<PathBuf>) -> Self
Constructor inheriting default stdout and stderr; use new()
to customize the streams.
sourcepub fn install(&self, package_name: &str) -> PyResult<&Self>
pub fn install(&self, package_name: &str) -> PyResult<&Self>
Installs a package in the PyEnv, returning itself to easily chain dependencies.
sourcepub fn try_install(&self, package_name: &str) -> &Self
pub fn try_install(&self, package_name: &str) -> &Self
An unwrapped install()
run, which panics upon failure. See install()
for the version
which returns a PyResult.
sourcepub fn execute(&self, code: &str) -> PyResult<&Self>
pub fn execute(&self, code: &str) -> PyResult<&Self>
Executes arbitrary code in the PyEnv, returning itself to easily chain runs.
sourcepub fn try_execute(&self, code: &str) -> &Self
pub fn try_execute(&self, code: &str) -> &Self
An unwrapped execute()
run, which panics upon failure. See execute()
for the version
which returns a PyResult.
sourcepub fn persistent(&mut self, persistent: bool) -> &Self
pub fn persistent(&mut self, persistent: bool) -> &Self
Makes the environment impersistent beyond the PyEnv, deleting it upon dropping
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PyEnv
impl !RefUnwindSafe for PyEnv
impl !Send for PyEnv
impl !Sync for PyEnv
impl Unpin for PyEnv
impl !UnwindSafe for PyEnv
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