Skip to content

Commit 1090a47

Browse files
authored
Docs: Fix HTTP Error 403 (#475)
Repeat Read the Docs CI bug fix as in BLAST-WarpX/warpx#6151. Not appearing here yet, but prevented this way.
1 parent cad77f2 commit 1090a47

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

docs/source/conf.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@
3131
# https://sphinx-rtd-theme.readthedocs.io/en/stable/installing.html
3232
import sphinx_rtd_theme # noqa
3333

34+
35+
def download_with_headers(url, filename):
36+
"""Download a file with proper User-Agent header to avoid 403 errors."""
37+
try:
38+
req = urllib.request.Request(
39+
url, headers={"User-Agent": "pyAMReX-docs-builder"}
40+
)
41+
with urllib.request.urlopen(req) as response:
42+
with open(filename, "wb") as f:
43+
f.write(response.read())
44+
except Exception as e:
45+
print(f"Could not download {filename} from {url}: {e}")
46+
print("Continuing build without cross-reference file...")
47+
48+
3449
# -- General configuration ------------------------------------------------
3550

3651
# If your documentation needs a minimal Sphinx version, state it here.
@@ -196,8 +211,10 @@
196211
highlight_language = "cpp"
197212

198213
# Download AMReX Doxygen Tagfiles to interlink Doxygen docs
199-
url = "https://amrex-codes.github.io/amrex/docs_xml/doxygen/amrex-doxygen-web.tag.xml"
200-
urllib.request.urlretrieve(url, "../amrex-doxygen-web.tag.xml")
214+
download_with_headers(
215+
url="https://amrex-codes.github.io/amrex/docs_xml/doxygen/amrex-doxygen-web.tag.xml",
216+
filename="../amrex-doxygen-web.tag.xml",
217+
)
201218

202219
# Build Doxygen
203220
subprocess.call(

0 commit comments

Comments
 (0)