diff --git a/.gitmodules b/.gitmodules index 59ee1f9..238ede9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,5 +2,5 @@ path = ucwmac url = git://git.ucw.cz/ucwmac.git [submodule "src/formatitko/katex-server"] - path = src/formatitko/katex-server + path = src/formatitko/katex_server url = https://gitea.ks.matfyz.cz:/KSP/formatitko-katex-server diff --git a/pyproject.toml b/pyproject.toml index 2466026..370d46e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,11 +33,19 @@ dependencies = [ [project.scripts] formatitko = "formatitko.formatitko:main" +[tool.setuptools.package-data] +"formatitko.katex_server" = [ + "*", + "node_modules/*", + "node_modules/katex/*", + "node_modules/katex/src/*", + "node_modules/katex/dist/*", +] + [tool.setuptools_scm] [tool.setuptools.packages.find] where = ["src"] -exclude = ["src/formatitko/katex-server/node_modules"] [tool.pyright] strictParameterNoneValue = false diff --git a/src/formatitko/katex.py b/src/formatitko/katex.py index f81db24..c6a62f6 100644 --- a/src/formatitko/katex.py +++ b/src/formatitko/katex.py @@ -46,20 +46,20 @@ class KatexClient: srcdir = os.path.dirname(os.path.realpath(__file__)) # Test if `node_modules` directory exists and if not, run `npm install` - if not os.path.isdir(srcdir + "/katex-server/node_modules"): + if not os.path.isdir(srcdir + "/katex_server/node_modules"): print("Installing node dependencies for the first time...") npm = shutil.which("npm") or shutil.which("yarnpkg") if npm is None: raise NPMNotFoundError("npm not found. Node.js is required to use KaTeX.") - subprocess.run([npm, "install"], cwd=srcdir+"/katex-server", check=True) + subprocess.run([npm, "install"], cwd=srcdir+"/katex_server", check=True) - self._katex_server_path = srcdir + "/katex-server/index.mjs" + self._katex_server_path = srcdir + "/katex_server/index.mjs" self._server_process = subprocess.Popen(["node", self._katex_server_path, self._socket_file], stdout=subprocess.PIPE) ok = self._server_process.stdout.readline() if ok != b"OK\n": - raise KatexServerError("Failed to connect to katex-server") + raise KatexServerError("Failed to connect to katex_server") def connect(self): self._client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) diff --git a/src/formatitko/katex-server b/src/formatitko/katex_server similarity index 100% rename from src/formatitko/katex-server rename to src/formatitko/katex_server