Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ strip = true
panic = "abort"

[patch.crates-io]
# Keep libc 0.2.191 compatible with iOS until nix releases https://github.com/nix-rust/nix/pull/2821.
nix = { git = "https://github.com/nix-rust/nix", rev = "f9ba3ed0698255d93240b07ecbf39ecb05a8a5cd" }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a good idea. wait new release

parking_lot_core = { git = "https://github.com/youknowone/parking_lot", branch = "rustpython" }
# REDOX START, Uncomment when you want to compile/check with redoxer
# REDOX END
Expand Down
13 changes: 8 additions & 5 deletions Lib/_ios_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
else:
# ctypes is available. Load the ObjC library, and wrap the objc_getClass,
# sel_registerName methods
lib = util.find_library("objc")
if lib is None:
# Failed to load the objc library
raise ImportError("ObjC runtime library couldn't be loaded")
# find_library() resolves a system library through the dyld shared cache,
# which needs _dyld_shared_cache_contains_path(); that is unavailable before
# iOS 14, so fall back to the bare name, which dyld resolves by itself.
lib = util.find_library("objc") or "libobjc.dylib"

objc = cdll.LoadLibrary(lib)
try:
objc = cdll.LoadLibrary(lib)
except OSError:
raise ImportError("ObjC runtime library couldn't be loaded")
objc.objc_getClass.restype = c_void_p
objc.objc_getClass.argtypes = [c_char_p]
objc.sel_registerName.restype = c_void_p
Expand Down
10 changes: 7 additions & 3 deletions crates/host_env/src/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::fs;
pub use crate::posix::rename;
#[cfg(any(unix, target_os = "wasi"))]
pub use crate::posix_unix_like::rename;
#[cfg(any(unix, windows))]
use core::ffi::CStr;
use core::str::Utf8Error;
#[cfg(windows)]
use core::time::Duration;
Expand Down Expand Up @@ -569,7 +567,13 @@ pub fn isatty(_fd: i32) -> bool {
}

#[cfg(any(unix, windows))]
pub fn system(command: &CStr) -> libc::c_int {
#[cfg(not(any(
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
)))]
pub fn system(command: &core::ffi::CStr) -> libc::c_int {
unsafe { libc::system(command.as_ptr()) }
}

Expand Down
5 changes: 4 additions & 1 deletion crates/host_env/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,12 @@ pub use libc::{MSG_CMSG_CLOEXEC, MSG_NOSIGNAL};
pub use libc::{
AF_SYSTEM, IP_ADD_SOURCE_MEMBERSHIP, IP_BLOCK_SOURCE, IP_DROP_SOURCE_MEMBERSHIP, IP_PKTINFO,
IP_RECVTTL, IP_UNBLOCK_SOURCE, IPPROTO_MAX, IPPROTO_SCTP, MSG_NOSIGNAL, PF_SYSTEM,
SYSPROTO_CONTROL, TCP_CONNECTION_INFO, TCP_KEEPALIVE,
TCP_CONNECTION_INFO, TCP_KEEPALIVE,
};

#[cfg(target_os = "macos")]
pub use libc::SYSPROTO_CONTROL;

#[cfg(target_os = "linux")]
pub use libc::{
CAN_BCM, CAN_EFF_FLAG, CAN_EFF_MASK, CAN_ERR_FLAG, CAN_ERR_MASK, CAN_ISOTP, CAN_J1939, CAN_RAW,
Expand Down
6 changes: 5 additions & 1 deletion crates/stdlib/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ mod _socket {

#[cfg(target_vendor = "apple")]
#[pyattr]
use host_socket::{AF_SYSTEM, PF_SYSTEM, SYSPROTO_CONTROL, TCP_KEEPALIVE};
use host_socket::{AF_SYSTEM, PF_SYSTEM, TCP_KEEPALIVE};

#[cfg(target_os = "macos")]
#[pyattr]
use host_socket::SYSPROTO_CONTROL;

#[cfg(target_vendor = "apple")]
#[pyattr]
Expand Down
16 changes: 14 additions & 2 deletions crates/vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ pub(super) mod _os {
#[cfg(not(windows))]
use crate::exceptions;
use crate::host_env::fileutils::StatStruct;
#[cfg(any(unix, windows))]
use crate::utils::ToCString;
use crate::{
AsObject, Py, PyObject, PyObjectRef, PyPayload, PyRef, PyResult,
builtins::{
Expand Down Expand Up @@ -1879,15 +1877,29 @@ pub(super) mod _os {
}

#[cfg(any(unix, windows))]
#[cfg(not(any(
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
)))]
#[derive(FromArgs)]
struct SystemArgs {
#[pyarg(any)]
command: PyStrRef,
}

#[cfg(any(unix, windows))]
#[cfg(not(any(
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos"
)))]
#[pyfunction]
fn system(command: SystemArgs, vm: &VirtualMachine) -> PyResult<i32> {
use crate::utils::ToCString;

let command = command.command;
let cstr = command.to_cstring(vm)?;
let x = crate::host_env::os::system(cstr.as_c_str());
Expand Down
Loading