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 Apr 5, 2024
1 parent 9f6519f commit 58a5e61
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,10 +6,10 @@ 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 pep440_rs::{Version, VersionSpecifiers};
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use std::env;
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 @@ -586,6 +589,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]);
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());
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 58a5e61

Please sign in to comment.