Skip to content

Commit b3141d1

Browse files
authored
mmap for windows (RustPython#6329)
1 parent 89bcae7 commit b3141d1

File tree

5 files changed

+527
-135
lines changed

5 files changed

+527
-135
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_mmap.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ def test_non_ascii_byte(self):
618618
self.assertEqual(m.read_byte(), b)
619619
m.close()
620620

621+
@unittest.expectedFailure # TODO: RUSTPYTHON
621622
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
622623
def test_tagname(self):
623624
data1 = b"0123456789"
@@ -867,6 +868,7 @@ def test_resize_fails_if_mapping_held_elsewhere(self):
867868
finally:
868869
f.close()
869870

871+
@unittest.expectedFailure # TODO: RUSTPYTHON
870872
@unittest.skipUnless(os.name == 'nt', 'requires Windows')
871873
def test_resize_succeeds_with_error_for_second_named_mapping(self):
872874
"""If a more than one mapping exists of the same name, none of them can

crates/stdlib/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,16 @@ chrono.workspace = true
9797
mac_address = "1.1.3"
9898
uuid = { version = "1.1.2", features = ["v1"] }
9999

100-
# mmap
101-
[target.'cfg(all(unix, not(target_arch = "wasm32")))'.dependencies]
102-
memmap2 = "0.5.10"
103-
page_size = "0.6"
104-
105100
[target.'cfg(all(unix, not(target_os = "redox"), not(target_os = "ios")))'.dependencies]
106101
termios = "0.3.3"
107102

108103
[target.'cfg(unix)'.dependencies]
109104
rustix = { workspace = true }
110105

106+
# mmap + socket dependencies
111107
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
108+
memmap2 = "0.9.9"
109+
page_size = "0.6"
112110
gethostname = "1.0.2"
113111
socket2 = { version = "0.6.0", features = ["all"] }
114112
dns-lookup = "3.0"
@@ -146,12 +144,15 @@ widestring = { workspace = true }
146144
[target.'cfg(windows)'.dependencies.windows-sys]
147145
workspace = true
148146
features = [
147+
"Win32_Foundation",
149148
"Win32_Networking_WinSock",
150149
"Win32_NetworkManagement_IpHelper",
151150
"Win32_NetworkManagement_Ndis",
152151
"Win32_Security_Cryptography",
152+
"Win32_Storage_FileSystem",
153153
"Win32_System_Environment",
154-
"Win32_System_IO"
154+
"Win32_System_IO",
155+
"Win32_System_Threading"
155156
]
156157

157158
[target.'cfg(target_os = "macos")'.dependencies]

crates/stdlib/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mod json;
3636
mod locale;
3737

3838
mod math;
39-
#[cfg(unix)]
39+
#[cfg(any(unix, windows))]
4040
mod mmap;
4141
mod opcode;
4242
mod pyexpat;
@@ -189,6 +189,9 @@ pub fn get_module_inits() -> impl Iterator<Item = (Cow<'static, str>, StdlibInit
189189
#[cfg(unix)]
190190
{
191191
"_posixsubprocess" => posixsubprocess::make_module,
192+
}
193+
#[cfg(any(unix, windows))]
194+
{
192195
"mmap" => mmap::make_module,
193196
}
194197
#[cfg(all(unix, not(target_os = "redox")))]

0 commit comments

Comments
 (0)