Skip to content

Commit 44a22a6

Browse files
committed
Check if we're using GNU sed instead of macOS
1 parent a6a666d commit 44a22a6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

build_docs.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,25 @@ def build(self):
657657
f"-D ogp_site_url={site_url}",
658658
)
659659

660+
def is_gnu_sed() -> bool:
661+
"""Check if we are using GNU sed."""
662+
try:
663+
subprocess.run(
664+
["sed", "--version"],
665+
stdout=subprocess.DEVNULL,
666+
stderr=subprocess.DEVNULL,
667+
check=True,
668+
)
669+
return True
670+
except subprocess.CalledProcessError:
671+
return False
672+
except FileNotFoundError:
673+
return False
674+
660675
# Disable CPython switchers, we handle them now:
661676
run(
662677
["sed", "-i"]
663-
+ ([""] if sys.platform == "darwin" else [])
678+
+ ([] if is_gnu_sed() else [""])
664679
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
665680
)
666681
self.versions.setup_indexsidebar(

0 commit comments

Comments
 (0)