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

Remove use of the sed command #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2025
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
8000
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 8000 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