-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
54 lines (42 loc) · 1.66 KB
/
Copy pathsetup.py
File metadata and controls
54 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""setup.py shim — metadata lives in ``pyproject.toml``.
This file exists solely to register a post-install hook that attempts to
install Graphviz's ``dot`` binary, which is required at runtime by the
overflow-graph rendering pipeline (pydot → dot). The binary cannot be
shipped as a Python wheel, so we shell out to the platform's package
manager. See ``expert_backend/install_graphviz.py`` for the per-OS logic.
Note: modern pip builds a wheel before installing, so the ``install``
``cmdclass`` only runs reliably for legacy / editable installs
(``pip install -e .``). For wheel-based flows users (and CI) should
run the bundled console script ``costudy4grid-install-graphviz`` —
this remains the cross-platform entry point.
"""
from __future__ import annotations
import os
import sys
from setuptools import setup
from setuptools.command.develop import develop
from setuptools.command.install import install
def _post_install() -> None:
if os.environ.get("COSTUDY4GRID_SKIP_GRAPHVIZ_INSTALL"):
return
try:
sys.path.insert(0, os.path.dirname(__file__))
from expert_backend import install_graphviz # type: ignore
install_graphviz.ensure_dot()
except Exception as exc: # noqa: BLE001 — best-effort, never block install
print(f"[co-study4grid] graphviz post-install skipped: {exc}",
file=sys.stderr)
class _PostInstall(install):
def run(self) -> None:
install.run(self)
_post_install()
class _PostDevelop(develop):
def run(self) -> None:
develop.run(self)
_post_install()
setup(
cmdclass={
"install": _PostInstall,
"develop": _PostDevelop,
},
)