Skip to content

Migrate Mathjax detection to meson #40404

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Move mathjax detection to docbuild meson file
  • Loading branch information
tobiasdiez committed Jul 11, 2025
commit 9dd0ab8eb37d6221bb2534befead4f5825915c5a
33 changes: 0 additions & 33 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -218,37 +218,4 @@ run_command(create_files_command, check: true)

root = meson.current_source_dir()

# MathJax detection logic
# Check for system-wide MathJax installation
mathjax_dir = ''
mathjax_found = false

# Check common system locations for MathJax
foreach dir : ['/usr/share/mathjax', '/usr/local/share/mathjax']
if not mathjax_found and fs.is_file(dir / 'tex-chtml.js')
mathjax_dir = dir
mathjax_found = true
message('Found MathJax at: ' + dir)
endif
endforeach

# If not found, use the bundled/prefix location
if not mathjax_found
mathjax_dir = get_option('prefix') / 'share' / 'mathjax' / 'mathjax'
message('Using bundled MathJax location: ' + mathjax_dir)
endif

# Generate the configuration template
mathjax_config_data = configuration_data()
mathjax_config_data.set('MATHJAX_DIR', mathjax_dir)

# Create config file in the build directory
configure_file(
input: 'src/sage_docbuild/mathjax_config.py.in',
output: 'mathjax_config.py',
configuration: mathjax_config_data,
install: true,
install_dir: get_option('prefix') / 'lib' / 'python' + py.language_version() / 'site-packages' / 'sage_docbuild'
)

subdir('src')
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,5 @@ src = meson.current_source_dir()

# Submodules
subdir('sage')
subdir('sage_docbuild')
subdir('doc')
10 changes: 2 additions & 8 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@
from sage.misc.sagedoc import extlinks as extlinks # noqa: PLC0414
from sage.misc.sagedoc_conf import * # Load configuration shared with sage.misc.sphinxify

# Import MathJax configuration from the build system
try:
from sage_docbuild.mathjax_config import MATHJAX_DIR
except ImportError:
# Fallback to default location if config file is not available
import os
MATHJAX_DIR = os.path.join(os.environ.get('SAGE_LOCAL', '/usr/local'), 'share', 'mathjax')
from .config import MATHJAX_PATH

# ---------------------
# General configuration
Expand Down Expand Up @@ -558,7 +552,7 @@ def linkcode_resolve(domain, info):
if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes':
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
else:
mathjax_path = os.path.join(MATHJAX_DIR, 'tex-chtml.js')
mathjax_path = MATHJAX_PATH

# A list of glob-style patterns that should be excluded when looking for source
# files. They are matched against the source file names relative to the
Expand Down
6 changes: 6 additions & 0 deletions src/sage_docbuild/config.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Documentation configuration generated by meson
"""

# MathJax path
MATHJAX_PATH: str = '@MATHJAX_PATH@'
8 changes: 0 additions & 8 deletions src/sage_docbuild/mathjax_config.py.in

This file was deleted.

21 changes: 21 additions & 0 deletions src/sage_docbuild/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Check for system-wide MathJax installation
mathjax_path = ''
mathjax_found = false
foreach dir : ['/usr/share/mathjax', '/usr/local/share/mathjax']
if not mathjax_found and fs.is_file(dir / 'tex-chtml.js')
mathjax_path = dir / 'tex-chtml.js'
mathjax_found = true
message('Found MathJax at: ' + dir)
endif
endforeach
if not mathjax_found
mathjax_path = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'
message('Using CDN MathJax: ' + mathjax_path)
endif
docs_config_data = configuration_data()
docs_config_data.set('MATHJAX_PATH', mathjax_path)
configure_file(
input: 'config.py.in',
output: 'config.py',
configuration: docs_config_data,
)
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy