-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add version check to evaluate if python can run
- Loading branch information
1 parent
c526e82
commit df3a2d0
Showing
6 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
use crate::dirs::{init_venv, read_pyproject}; | ||
use clap::Args; | ||
use std::path::PathBuf; | ||
use std::{ffi::OsString, path::PathBuf}; | ||
|
||
#[derive(Args, Debug)] | ||
#[command(author, version, about)] | ||
pub struct Python { | ||
#[arg(short, long, default_value = ".")] | ||
pub project_dir: PathBuf, | ||
#[arg(last = true)] | ||
pub slop: Vec<OsString>, | ||
} | ||
|
||
pub async fn python(args: Python) -> crate::error::Result<()> { | ||
let _ = read_pyproject(&args.project_dir).await?; | ||
let env = init_venv(&args.project_dir).await?; | ||
env.python_cmd().spawn()?.wait().await?; | ||
let mut cmd = env.python_cmd(); | ||
for arg in args.slop { | ||
cmd.arg(arg); | ||
} | ||
cmd.spawn()?.wait().await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use pyo3::Python; | ||
|
||
lazy_static::lazy_static! { | ||
static ref VERSION: String = format!( | ||
"{}\nPython {}", | ||
clap::crate_version!(), | ||
Python::with_gil(|py| py.version().to_string()) | ||
); | ||
} | ||
|
||
pub fn version() -> clap::builder::Str { | ||
VERSION.as_str().into() | ||
} |