Pytigon's library system provides a structured way to share code across applications within a project. Libraries are auto-discovered and loaded at runtime — you just create the right directory and put your Python modules there.
Pytigon searches for libraries in three locations, with a clear hierarchy:
[app]/applib/Code specific to a single application but organized as separate modules:
myapp/
├── applib/
│ ├── __init__.py
│ ├── utils.py # Shared utility functions
│ ├── validators.py # Custom validators
│ └── reports.py # Report generation logic
├── models.py
└── views.py
[PRJ]/prjlib/Code shared across all applications within the project. These are automatically added to the Python path:
[PRJ]/
├── prjlib/
│ ├── __init__.py
│ ├── common_utils.py # Utilities used by multiple apps
│ └── base_views.py # Shared base view classes
├── myapp/
└── settings_app.py
[DATA]/[PRJ]/prjlib/Packages installed via ptig pip install end up here. These are project-specific dependencies that don't pollute the global Python environment.
[DATA]/[PRJ]/syslib/C, C++, Nim, and Zig extensions compiled automatically during source installation. These bypass the Python GIL for performance-critical operations.
Libraries are imported automatically at startup. The import mechanism:
applib/prjlib/sys.pathYou can import from any library location using standard Python imports:
# From application library
from applib.utils import my_function
# From project library (also imported as 'prjlib')
from prjlib.common_utils import shared_constant
# Direct import also works
import applib.validators
Pytigon itself is organized as a library collection. The core libraries available in every project are:
| Library | Purpose |
|---|---|
schdjangoext |
Django extensions — JSONModel, FastForm, fields, widgets |
schviews |
Generic views — TableView, FormView, TreeView |
schhtml |
Rendering engine — HTML/PDF/ODF generation |
schfs |
Virtual filesystem abstraction |
schindent |
.ihtml template preprocessor |
schtable |
Table data structures |
schtasks |
Background task scheduling |
schparser |
HTML parsing utilities |
schspreadsheet |
Spreadsheet (ODF/XLSX) processing |
schtools |
Various utilities — images, encryption, installation |
schhttptools |
HTTP client, REST client, WebSocket tools |
schandroid |
Android/Kivy client components |
applib/ focused — If code is used by multiple applications, promote it to prjlib/prjlib/ for shared business logic — Validators, base classes, utility functionssyslib/ directory supports C, Nim, and Zig modules that compile automatically on installation