pyo3/.netlify/create_redirects.py

25 lines
766 B
Python
Raw Normal View History

2022-08-16 17:42:26 +00:00
#!/usr/bin/env python
"""Generates _redirects file for netlify.
Run this and write output to .netlify/_redirects and check into
the PyO3 repository.
"""
import subprocess
def main() -> None:
versions = subprocess.check_output(["git", "tag"], text=True).splitlines()
for version in versions:
version_without_v = version.lstrip("v")
2022-12-18 07:48:22 +00:00
# redirect doc requests to docs.rs
2022-08-16 17:42:26 +00:00
print(f"/{version}/doc/* https://docs.rs/pyo3/{version_without_v}/:splat")
2022-12-18 07:48:22 +00:00
# proxy guide to github-pages hosting
print(f"/{version}/* https://pyo3.github.io/pyo3/{version}/:splat 200")
# proxy benchmarks to github-pages hosting
2022-12-18 07:48:22 +00:00
print(f"/dev/bench/* https://pyo3.github.io/pyo3/dev/bench/:splat 200")
2022-08-16 17:42:26 +00:00
if __name__ == "__main__":
main()