Skip to content

Commit 7a9bca9

Browse files
authored
Remove use of the sed command (#272)
1 parent c341248 commit 7a9bca9

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

build_docs.py

+6-36
Original file line numberDiff line numberDiff line change
@@ -646,21 +646,6 @@ def build(self):
646646
"-D gettext_compact=0",
647647
"-D translation_progress_classes=1",
648648
))
649-
if self.language.tag == "ja":
650-
# Since luatex doesn't support \ufffd, replace \ufffd with '?'.
651-
# https://gist.github.com/zr-tex8r/e0931df922f38fbb67634f05dfdaf66b
652-
# Luatex already fixed this issue, so we can remove this once Texlive
653-
# is updated.
654-
# (https://github.com/TeX-Live/luatex/commit/af5faf1)
655-
subprocess.check_output(
656-
"sed -i s/\N{REPLACEMENT CHARACTER}/?/g "
657-
f"{locale_dirs}/ja/LC_MESSAGES/**/*.po",
658-
shell=True,
659-
)
660-
subprocess.check_output(
661-
f"sed -i s/\N{REPLACEMENT CHARACTER}/?/g {self.checkout}/Doc/**/*.rst",
662-
shell=True,
663-
)
664649

665650
if self.version.status == "EOL":
666651
sphinxopts.append("-D html_context.outdated=1")
@@ -687,27 +672,12 @@ def build(self):
687672
f"-D ogp_site_url={site_url}",
688673
)
689674

690-
def is_gnu_sed() -> bool:
691-
"""Check if we are using GNU sed."""
692-
try:
693-
subprocess.run(
694-
["sed", "--version"],
695-
stdout=subprocess.DEVNULL,
696-
stderr=subprocess.DEVNULL,
697-
check=True,
698-
)
699-
return True
700-
except subprocess.CalledProcessError:
701-
return False
702-
except FileNotFoundError:
703-
return False
704-
705-
# Disable CPython switchers, we handle them now:
706-
run(
707-
["sed", "-i"]
708-
+ ([] if is_gnu_sed() else [""])
709-
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
710-
)
675+
if self.version.as_tuple() < (3, 8):
676+
# Disable CPython switchers, we handle them now:
677+
text = (self.checkout / "Doc" / "Makefile").read_text(encoding="utf-8")
678+
text = text.replace(" -A switchers=1", "")
679+
(self.checkout / "Doc" / "Makefile").write_text(text, encoding="utf-8")
680+
711681
self.versions.setup_indexsidebar(
712682
self.version,
713683
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html",

0 commit comments

Comments
 (0)