pub struct PythonManager { /* private fields */ }Expand description
Python version manager
Manages Python installations in ~/.local/share/rx/python/
Implementations§
Source§impl PythonManager
impl PythonManager
Sourcepub fn with_dirs(install_dir: PathBuf, config_dir: PathBuf) -> Result<Self>
pub fn with_dirs(install_dir: PathBuf, config_dir: PathBuf) -> Result<Self>
Create a manager with custom directories (for testing)
Sourcepub fn install_dir(&self) -> &Path
pub fn install_dir(&self) -> &Path
Get the installation directory
Sourcepub fn config_dir(&self) -> &Path
pub fn config_dir(&self) -> &Path
Get the config directory
Sourcepub async fn install(&self, version_spec: &str) -> Result<InstalledPython>
pub async fn install(&self, version_spec: &str) -> Result<InstalledPython>
Install a Python version
If a short version like “3.12” is provided, installs the latest patch version.
Sourcepub fn list_installed(&self) -> Result<Vec<InstalledPython>>
pub fn list_installed(&self) -> Result<Vec<InstalledPython>>
List installed Python versions
Sourcepub fn get(&self, version_spec: &str) -> Result<Option<InstalledPython>>
pub fn get(&self, version_spec: &str) -> Result<Option<InstalledPython>>
Get a specific installed version
Sourcepub fn find_matching(
&self,
version_spec: &str,
) -> Result<Option<InstalledPython>>
pub fn find_matching( &self, version_spec: &str, ) -> Result<Option<InstalledPython>>
Find an installed version matching a specification
Returns the highest patch version that matches.
Sourcepub fn pin(&self, version_spec: &str, project_dir: &Path) -> Result<()>
pub fn pin(&self, version_spec: &str, project_dir: &Path) -> Result<()>
Pin a Python version for a project by creating .python-version file
Sourcepub fn read_pin(&self, project_dir: &Path) -> Result<Option<PythonVersion>>
pub fn read_pin(&self, project_dir: &Path) -> Result<Option<PythonVersion>>
Read the pinned version from .python-version file
Sourcepub fn set_global(&self, version_spec: &str) -> Result<()>
pub fn set_global(&self, version_spec: &str) -> Result<()>
Set the global default Python version
Sourcepub fn get_global(&self) -> Result<Option<PythonVersion>>
pub fn get_global(&self) -> Result<Option<PythonVersion>>
Get the global default Python version
Sourcepub fn list_available(&self) -> Vec<AvailableVersion>
pub fn list_available(&self) -> Vec<AvailableVersion>
Get a list of all available versions (not installed)
Sourcepub fn resolve_python(&self, project_dir: &Path) -> Result<PathBuf>
pub fn resolve_python(&self, project_dir: &Path) -> Result<PathBuf>
Resolve the Python executable to use for a project
Checks (in order):
- .python-version in project
- Global config
- System Python