Skip to content

Commit f1062c9

Browse files
committed
imgmath: Make lockfile optional
1 parent ebd9d24 commit f1062c9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ dependencies = [
8484
"roman-numerals-py>=1.0.0",
8585
"packaging>=23.0",
8686
"colorama>=0.4.6; sys_platform == 'win32'",
87-
"filelock>=3.0",
8887
]
8988
dynamic = ["version"]
9089

@@ -108,6 +107,9 @@ lint = [
108107
"pypi-attestations==0.0.25",
109108
"betterproto==2.0.0b6",
110109
]
110+
package = [
111+
"filelock>=3.0",
112+
]
111113
test = [
112114
"pytest>=8.0",
113115
"pytest-xdist[psutil]>=3.4",

sphinx/ext/imgmath.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from subprocess import CalledProcessError
1818
from typing import TYPE_CHECKING
1919

20-
import filelock
2120
from docutils import nodes
2221

2322
import sphinx
@@ -275,7 +274,12 @@ def render_math(
275274
lock: Any = contextlib.nullcontext()
276275
if self.builder.parallel_ok:
277276
lockfile = generated_path.with_suffix(generated_path.suffix + '.lock')
278-
lock = filelock.FileLock(lockfile)
277+
try:
278+
import filelock # type: ignore[import-not-found]
279+
280+
lock = filelock.FileLock(lockfile)
281+
except ImportError:
282+
pass
279283

280284
with lock:
281285
if not generated_path.is_file():

0 commit comments

Comments
 (0)