pub struct PythonManager {
uv_binary: PathBuf,
python_dir: PathBuf,
venv_dir: PathBuf,
scripts_dir: PathBuf,
templates_dir: PathBuf,
initialized: OnceCell<()>,
}Fields§
§uv_binary: PathBuf§python_dir: PathBuf§venv_dir: PathBuf§scripts_dir: PathBuf§templates_dir: PathBuf§initialized: OnceCell<()>Lazy initialization avoids downloading uv at startup if Python is never used
Implementations§
Source§impl PythonManager
impl PythonManager
pub async fn new() -> Result<Arc<Self>>
async fn ensure_initialized(&self) -> Result<()>
Sourceasync fn download_uv(&self) -> Result<()>
async fn download_uv(&self) -> Result<()>
Downloads uv binary and verifies SHA256 checksum to prevent supply chain attacks. Uses a fixed version instead of ‘latest’ for reproducibility and security.
Sourceasync fn extract_tar_gz(&self, archive_path: &Path) -> Result<()>
async fn extract_tar_gz(&self, archive_path: &Path) -> Result<()>
Extract tar.gz archive
Sourceasync fn extract_zip(&self, archive_path: &Path) -> Result<()>
async fn extract_zip(&self, archive_path: &Path) -> Result<()>
Extract zip archive (Windows)
async fn setup_environment(&self) -> Result<()>
Sourcepub async fn execute_script(
&self,
script_name: &str,
input: Value,
) -> Result<Value>
pub async fn execute_script( &self, script_name: &str, input: Value, ) -> Result<Value>
Executes a Python script in an isolated subprocess with JSON I/O. Scripts receive input via stdin and must output valid JSON to stdout.
pub async fn save_script(&self, name: &str, content: &str) -> Result<PathBuf>
pub async fn list_scripts(&self) -> Result<Vec<String>>
pub fn is_ready(&self) -> bool
Sourcepub async fn execute_inline_code(
&self,
code: &str,
input: Value,
env_vars: HashMap<String, String>,
) -> Result<Value>
pub async fn execute_inline_code( &self, code: &str, input: Value, env_vars: HashMap<String, String>, ) -> Result<Value>
Execute inline Python code with PEP 723 dependencies using uv run
Sourcepub async fn list_templates(&self) -> Result<Vec<TemplateInfo>>
pub async fn list_templates(&self) -> Result<Vec<TemplateInfo>>
List all available Python script templates by scanning .py files
Sourcefn parse_metadata_block(content: &str) -> Result<HashMap<String, String>>
fn parse_metadata_block(content: &str) -> Result<HashMap<String, String>>
Parse metadata block from Python file
Sourcefn parse_dependencies_block(content: &str) -> Result<Vec<String>>
fn parse_dependencies_block(content: &str) -> Result<Vec<String>>
Parse dependencies block from Python file (PEP 723 format)
Sourcepub async fn get_template(
&self,
template_id: &str,
) -> Result<HashMap<String, String>>
pub async fn get_template( &self, template_id: &str, ) -> Result<HashMap<String, String>>
Get a specific template by ID
Sourcefn strip_metadata_blocks(content: &str) -> String
fn strip_metadata_blocks(content: &str) -> String
Remove metadata and script blocks from Python code
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PythonManager
impl RefUnwindSafe for PythonManager
impl Send for PythonManager
impl Sync for PythonManager
impl Unpin for PythonManager
impl UnwindSafe for PythonManager
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