Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check if we're using GNU sed instead of macOS #263

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 1 commit into from
Apr 11, 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
Diff view
17 changes: 16 additions & 1 deletion build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,25 @@ 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
Comment on lines +660 to +673
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a module-level function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be! This is the only place its used, so I think it's okay here, but happy to move if you like.


# Disable CPython switchers, we handle them now:
run(
["sed", "-i"]
+ ([""] if sys.platform == "darwin" else [])
+ ([] if is_gnu_sed() else [""])
+ ["s/ *-A switchers=1//", self.checkout / "Doc" / "Makefile"]
)
self.versions.setup_indexsidebar(
Expand Down