Skip to content

Commit 96bdc21

Browse files
docs: monkey patch PROT_READ to enable docs build on Windows (#461)
1 parent abc4ecd commit 96bdc21

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

docs/source/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
import ctypes
1010

11+
# Monkey-patch PROT_READ into mmap if missing (Windows), so that we can
12+
# import mss.linux.xshmgetimage while building the documentation.
13+
import mmap
14+
15+
if not hasattr(mmap, "PROT_READ"):
16+
mmap.PROT_READ = 1 # type:ignore[attr-defined]
17+
1118
import mss
1219

1320
# -- General configuration ------------------------------------------------
@@ -44,7 +51,6 @@
4451
ctypes.WINFUNCTYPE = ctypes.CFUNCTYPE # type:ignore[attr-defined]
4552
ctypes.WinError = lambda _code=None, _descr=None: OSError() # type:ignore[attr-defined]
4653

47-
4854
# -- Options for HTML output ----------------------------------------------
4955

5056
html_theme = "shibuya"

0 commit comments

Comments
 (0)