Debian Codegraph @

src/target/legacy_py.rs

raw
1 //! This module is taken mostly verbatim from PyPI's `legacy.py` validation logic.
2 //!
3 //! <https://github.com/pypi/warehouse/blob/main/warehouse/forklift/legacy.py>
4
5 use once_cell::sync::Lazy;
6 use regex::Regex;
7
8 pub(super) static MACOS_PLATFORM_RE: Lazy<Regex> =
9 Lazy::new(|| Regex::new(r"^macosx_(?P<major>\d+)_(?:\d+)_(?P<arch>.+)$").unwrap());
10
11 pub(super) static IOS_PLATFORM_RE: Lazy<Regex> = Lazy::new(|| {
12 Regex::new(r"^ios_(?:\d+)_(?:\d+)_(?P<arch>.+)_(?:iphoneos|iphonesimulator)$").unwrap()
13 });
14
15 pub(super) static ANDROID_PLATFORM_RE: Lazy<Regex> =
16 Lazy::new(|| Regex::new(r"^android_(?:\d+)_(?P<arch>.+)$").unwrap());
17
18 pub(super) static LINUX_PLATFORM_RE: Lazy<Regex> = Lazy::new(|| {
19 Regex::new(r"^(?P<libc>(?:many|musl))linux_(?:\d+)_(?:\d+)_(?P<arch>.+)$").unwrap()
20 });
21
22 /// Contains also non-Rust platforms to match `legacy.py` verbatim.
23 pub(super) static ALLOWED_PLATFORMS: &[&str] = &[
24 "any",
25 "win32",
26 "win_arm64",
27 "win_amd64",
28 "win_ia64",
29 "manylinux1_x86_64",
30 "manylinux1_i686",
31 "manylinux2010_x86_64",
32 "manylinux2010_i686",
33 "manylinux2014_x86_64",
34 "manylinux2014_i686",
35 "manylinux2014_aarch64",
36 "manylinux2014_armv7l",
37 "manylinux2014_ppc64",
38 "manylinux2014_ppc64le",
39 "manylinux2014_s390x",
40 "linux_armv6l",
41 "linux_armv7l",
42 ];
43
44 /// Windows platforms: win32 (i686), win_amd64 (x86_64), win_arm64 (aarch64).
45 ///
46 /// PyPI allows win_ia64 but Rust doesn't support IA64/Itanium.
47 pub(super) static WINDOWS_ARCHES: &[&str] = &["x86_64", "i686", "aarch64"];
48
49 /// Reduced list only containing targets support by both Rust/maturin and PyPI.
50 pub(super) static MACOS_ARCHES: &[&str] = &["x86_64", "arm64", "i686", "universal2"];
51
52 /// Those are actually hardcoded in warehouse in the same way.
53 pub(super) static MACOS_MAJOR_VERSIONS: &[&str] = &["10", "11", "12", "13", "14", "15"];
54
55 pub(super) static IOS_ARCHES: &[&str] = &["arm64", "x86_64"];
56
57 pub(super) static ANDROID_ARCHES: &[&str] = &["armeabi_v7a", "arm64_v8a", "x86", "x86_64"];
58
59 pub(super) static MANYLINUX_ARCHES: &[&str] = &[
60 "x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x", "ppc64", "riscv64",
61 ];
62
63 pub(super) static MUSLLINUX_ARCHES: &[&str] =
64 &["x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x"];