Skip to content

Commit

Permalink
feat: add allow prerelease flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fatelei committed Mar 25, 2024
1 parent 9f6519f commit 4dc3ce8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/build_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use crate::project_layout::ProjectResolver;
use crate::pyproject_toml::ToolMaturin;
use crate::python_interpreter::{InterpreterConfig, InterpreterKind, MINIMUM_PYTHON_MINOR};
use crate::{BuildContext, PythonInterpreter, Target};
use anyhow::{bail, format_err, Context, Result};
use anyhow::{bail, format_err, Context, Ok, Result};
use cargo_metadata::{Metadata, Node};
use cargo_options::heading;
use pep440_rs::VersionSpecifiers;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::env;
use std::ops::{Deref, DerefMut};
use std::ops::{ControlFlow, Deref, DerefMut};
use std::path::PathBuf;
use tracing::debug;

Expand Down Expand Up @@ -175,6 +175,9 @@ pub struct BuildOptions {
#[arg(short = 'f', long, conflicts_with = "interpreter")]
pub find_interpreter: bool,

#[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>,
Expand Down Expand Up @@ -560,6 +563,16 @@ impl BuildOptions {
let generate_import_lib = is_generating_import_lib(&cargo_metadata)?;
let interpreter = if self.find_interpreter {
// Auto-detect interpreters
let requires_python = metadata23.requires_python.as_ref();
if requires_python.is_some() {
let versions = requires_python.unwrap();
let has_pre_release = versions.iter().any(|v| v.any_prerelease());
if has_pre_release && !self.allow_prereleases {
print!("⚠️ Warning: python version is pre release, need pass flag --allow-prereleases");
ControlFlow::Break(());
}
}

self.find_interpreters(
&bridge,
&[],
Expand Down
1 change: 1 addition & 0 deletions src/develop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ pub fn develop(develop_options: DevelopOptions, venv_dir: &Path) -> Result<()> {
platform_tag: vec![PlatformTag::Linux],
interpreter: vec![python.clone()],
find_interpreter: false,
allow_prereleases: true,
bindings,
out: Some(wheel_dir.path().to_path_buf()),
skip_auditwheel: false,
Expand Down

0 comments on commit 4dc3ce8

Please sign in to comment.