8000 Remove use of the `sed` command by AA-Turner · Pull Request #272 · python/docsbuild-scripts · GitHub
[go: up one dir, main page]

Skip to content
Merged
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
42 changes: 6 additions & 36 deletions build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,21 +646,6 @@ def build(self):
"-D gettext_compact=0",
"-D translation_progress_classes=1",
))
if self.language.tag == "ja":
# Since luatex doesn't support \ufffd, replace \ufffd with '?'.
# https://gist.github.com/zr-tex8r/e0931df922f38fbb67634f05dfdaf66b
# Luatex already fixed this issue, so we can remove this once Texlive
# is updated.
# (https://github.com/TeX-Live/luatex/commit/af5faf1)
subprocess.check_output(
"sed -i s/\N{REPLACEMENT CHARACTER}/?/g "
f"{locale_dirs}/ja/LC_MESSAGES/**/*.po",
shell=True,
)
subprocess.check_output(
f"sed -i s/\N{REPLACEMENT CHARACTER}/?/g {self.checkout}/Doc/**/*.rst",
shell=True,
)

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

def is_gnu_sed() -> bool:
"""Check if we are using GNU sed."""
try:
subprocess.run(
["sed", "--version"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
check=True,
)
return True
except subprocess.CalledProcessError:
return False
except FileNotFoundError:
return False

# Disable CPython switchers, we handle them now:
run(
["sed", "-i"]
+ ([] if is_gnu_sed() else [""])
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
)
if self.version.as_tuple() < (3, 8):
# Disable CPython switchers, we handle them now:
text = (self.checkout / "Doc" / "Makefile").read_text(encoding="utf-8")
text = text.replace(" -A switchers=1", "")
(self.checkout / "Doc" / "Makefile").write_text(text, encoding="utf-8")

self.versions.setup_indexsidebar(
self.version,
self.checkout / "Doc" / "tools" / "templates" / "indexsidebar.html",
Expand Down
0