Skip to content

Commit

Permalink
propagate abiflags to wheel name on Windows (#2325)
Browse files Browse the repository at this point in the history
xref pydantic/jiter#172 (comment)

At the moment the windows builds are hard coded to use the `none` abi
tag (unless they are abi3). I think this is probably technically
incorrect, though in practice has worked fine historically because there
was only one build on Windows... until 3.13t has come along with
free-threading as a second option :)

It's important that we do emit proper abi tags (e.g. `cp313`, `cp313t`)
because otherwise the two 3.13 wheels end up with the same name and
can't be uploaded to PyPI. I think I also saw some install failures on
`jiter` CI where a Python 3.13 build ended up installing the other
build's wheel (I think `pip` detected an incorrect lib name and rejected
it).

I suspect I might need to fix some tests...
  • Loading branch information
davidhewitt authored Nov 28, 2024
1 parent 4e61f3b commit d7f11c9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
9 changes: 6 additions & 3 deletions src/python_interpreter/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ impl InterpreterConfig {
})
}
(Os::Windows, CPython) => {
let abiflags = if python_version < (3, 8) {
"m".to_string()
} else {
abiflags.to_string()
};
let ext_suffix = if python_version < (3, 8) {
".pyd".to_string()
} else {
Expand All @@ -135,8 +140,7 @@ impl InterpreterConfig {
major,
minor,
interpreter_kind: CPython,
// abiflags is always empty on Windows
abiflags: String::new(),
abiflags,
ext_suffix,
pointer_width: Some(target.pointer_width()),
gil_disabled,
Expand All @@ -152,7 +156,6 @@ impl InterpreterConfig {
major,
minor,
interpreter_kind: PyPy,
// abiflags is always empty on Windows
abiflags: String::new(),
ext_suffix,
pointer_width: Some(target.pointer_width()),
Expand Down
40 changes: 21 additions & 19 deletions src/python_interpreter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use self::config::InterpreterConfig;
use crate::auditwheel::PlatformTag;
use crate::{BridgeModel, BuildContext, Target};
use anyhow::{bail, format_err, Context, Result};
use anyhow::{bail, ensure, format_err, Context, Result};
use pep440_rs::{Version, VersionSpecifiers};
use regex::Regex;
use serde::Deserialize;
Expand Down Expand Up @@ -427,7 +427,19 @@ fn fun_with_abiflags(
Ok("".to_string())
} else if message.system == "windows" {
if matches!(message.abiflags.as_deref(), Some("") | None) {
Ok("".to_string())
// windows has a few annoying cases, but its abiflags in sysconfig always empty
// python <= 3.7 has "m"
if message.minor <= 7 {
Ok("m".to_string())
} else if message.gil_disabled {
ensure!(
message.minor >= 13,
"gil_disabled is only available in python 3.13+ ಠ_ಠ"
);
Ok("t".to_string())
} else {
Ok("".to_string())
}
} else {
bail!("A python 3 interpreter on Windows does not define abiflags in its sysconfig ಠ_ಠ")
}
Expand Down Expand Up @@ -499,23 +511,13 @@ impl PythonInterpreter {
} else {
match self.interpreter_kind {
InterpreterKind::CPython => {
if target.is_unix() {
format!(
"cp{major}{minor}-cp{major}{minor}{abiflags}-{platform}",
major = self.major,
minor = self.minor,
abiflags = self.abiflags,
platform = platform
)
} else {
// On windows the abiflags are missing, but this seems to work
format!(
"cp{major}{minor}-none-{platform}",
major = self.major,
minor = self.minor,
platform = platform
)
}
format!(
"cp{major}{minor}-cp{major}{minor}{abiflags}-{platform}",
major = self.major,
minor = self.minor,
abiflags = self.abiflags,
platform = platform
)
}
InterpreterKind::PyPy => {
// pypy uses its version as part of the ABI, e.g.
Expand Down

0 comments on commit d7f11c9

Please sign in to comment.