jettex.utils¶
Utility functions for platform detection, paths, and execution.
Module Overview¶
This module provides low-level utilities used by other modules.
from jettex import (
is_tinytex_installed,
get_tinytex_root,
get_bin_dir,
get_executable,
ensure_tinytex_in_path
)
Functions¶
get_platform()
¶
Get the current platform identifier.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
'windows', 'darwin', or 'linux' |
Source code in jettex/utils.py
get_arch()
¶
Get the current CPU architecture.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
'x86_64', 'aarch64', or 'i386' |
Source code in jettex/utils.py
get_download_url(version=1, release_version='')
¶
Get the download URL for TinyTeX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
int
|
TinyTeX version (0, 1, or 2) |
1
|
release_version
|
str
|
Specific release version (e.g., 'v2025.12'), or empty for latest |
''
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Full download URL |
Source code in jettex/utils.py
get_default_install_dir()
¶
Get the default TinyTeX installation directory.
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Default installation directory |
Source code in jettex/utils.py
get_tinytex_root()
¶
Get the TinyTeX root directory if installed.
Checks environment variable TINYTEX_HOME first, then default location.
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path or None: TinyTeX root directory if found |
Source code in jettex/utils.py
get_bin_dir()
¶
Get the TinyTeX bin directory containing executables.
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path or None: bin directory if found |
Source code in jettex/utils.py
get_executable(name)
¶
Get the path to a TinyTeX executable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Executable name (e.g., 'pdflatex', 'tlmgr') |
required |
Returns:
| Type | Description |
|---|---|
Optional[Path]
|
Path or None: Full path to executable if found |
Source code in jettex/utils.py
is_tinytex_installed()
¶
Check if TinyTeX is installed.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if TinyTeX is installed and usable |
Source code in jettex/utils.py
add_to_path(directory)
¶
Add a directory to the current process PATH.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path
|
Directory to add to PATH |
required |
Source code in jettex/utils.py
ensure_tinytex_in_path()
¶
Ensure TinyTeX bin directory is in PATH.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if TinyTeX is available in PATH |
Source code in jettex/utils.py
run_command(cmd, cwd=None, capture_output=True, check=False, timeout=None)
¶
Run a command and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
List[str]
|
Command and arguments as list |
required |
cwd
|
Optional[Path]
|
Working directory |
None
|
capture_output
|
bool
|
Capture stdout/stderr |
True
|
check
|
bool
|
Raise exception on non-zero exit |
False
|
timeout
|
Optional[int]
|
Command timeout in seconds |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CompletedProcess |
CompletedProcess
|
Result of the command |
Source code in jettex/utils.py
Examples¶
Platform Detection¶
from jettex.utils import get_platform, get_arch
platform = get_platform() # 'darwin', 'linux', or 'windows'
arch = get_arch() # 'x86_64', 'aarch64', etc.
print(f"Running on {platform} ({arch})")
Finding Executables¶
from jettex import get_executable, get_bin_dir
# Get bin directory
bin_dir = get_bin_dir()
print(f"Binaries at: {bin_dir}")
# Find specific executable
pdflatex = get_executable("pdflatex")
if pdflatex:
print(f"pdflatex: {pdflatex}")
PATH Management¶
from jettex import ensure_tinytex_in_path
# Add TinyTeX to current process PATH
if ensure_tinytex_in_path():
print("TinyTeX is now in PATH")
Check Installation¶
from jettex import is_tinytex_installed, get_tinytex_root
if is_tinytex_installed():
root = get_tinytex_root()
print(f"TinyTeX installed at: {root}")
else:
print("TinyTeX not installed")
Platform-Specific Paths¶
| Platform | Default Install Dir | Bin Subdir |
|---|---|---|
| Windows | %APPDATA%\TinyTeX |
bin\win32 |
| macOS | ~/Library/TinyTeX |
bin/universal-darwin |
| Linux (x86_64) | ~/.TinyTeX |
bin/x86_64-linux |
| Linux (arm64) | ~/.TinyTeX |
bin/aarch64-linux |