-
-
Notifications
You must be signed in to change notification settings - Fork 370
feat: add allow prerelease flag #2006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ use crate::{BuildContext, PythonInterpreter, Target}; | |
| use anyhow::{bail, format_err, Context, Result}; | ||
| use cargo_metadata::{Metadata, Node}; | ||
| use cargo_options::heading; | ||
| use pep440_rs::VersionSpecifiers; | ||
| use pep440_rs::{Version, VersionSpecifiers}; | ||
| use serde::{Deserialize, Serialize}; | ||
| use std::collections::{HashMap, HashSet}; | ||
| use std::env; | ||
|
|
@@ -175,6 +175,10 @@ pub struct BuildOptions { | |
| #[arg(short = 'f', long, conflicts_with = "interpreter")] | ||
| pub find_interpreter: bool, | ||
|
|
||
| /// Allow prerelease python interpreters | ||
| #[arg(long)] | ||
| pub allow_prereleases: bool, | ||
|
|
||
| /// Which kind of bindings to use. | ||
| #[arg(short, long, value_parser = ["pyo3", "pyo3-ffi", "rust-cpython", "cffi", "uniffi", "bin"])] | ||
| pub bindings: Option<String>, | ||
|
|
@@ -559,7 +563,7 @@ impl BuildOptions { | |
| }; | ||
|
|
||
| let generate_import_lib = is_generating_import_lib(&cargo_metadata)?; | ||
| let interpreter = if self.find_interpreter { | ||
| let mut interpreter = if self.find_interpreter { | ||
| // Auto-detect interpreters | ||
| self.find_interpreters( | ||
| &bridge, | ||
|
|
@@ -587,6 +591,16 @@ impl BuildOptions { | |
| self.find_interpreters(&bridge, &interpreter, &target, None, generate_import_lib)? | ||
| }; | ||
|
|
||
| if !self.allow_prereleases { | ||
| interpreter.retain(|interp| { | ||
| let version = Version::new([interp.config.major as u64, interp.config.minor as u64]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't be enough, I think it also need patch version.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. interp config only has major and minor, missing micro,we should pass minor to it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can modify interp config to add more detailed version info.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can remove
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| if version.any_prerelease() { | ||
| eprintln!("⚠️ Warning: python version is pre release, need pass flag --allow-prereleases"); | ||
| } | ||
| !version.any_prerelease() | ||
| }); | ||
| } | ||
|
|
||
| if cargo_options.args.is_empty() { | ||
| // if not supplied on command line, try pyproject.toml | ||
| let tool_maturin = pyproject.and_then(|p| p.maturin()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.