Created sls_build_backend module to help build the python module

This commit is contained in:
Kyler Olsen 2025-12-02 22:22:53 -07:00
parent 3c288e9165
commit c1db0937a2
8 changed files with 34 additions and 43 deletions

View File

@ -1,2 +0,0 @@
include scripts/*.py
include scripts/*.in

View File

@ -1,42 +1,17 @@
# SLS Python # SLS Python
This directory contains a minimal Python project skeleton intended to reimplement ## Building
functionality from the C `SLS` project found at the repository root.
Layout
- `src/sls/` — Python package with module skeletons: `lexer`, `parser`, `interpreter`, `builtin`, `repl`, and `cli`.
- `tests/` — pytest tests (start with `test_import.py`).
- `pyproject.toml` — project metadata and `sls` console script entrypoint.
- `requirements-dev.txt` — developer/test tools.
Quick start
Create a venv and install editable package + dev requirements:
```bash ```bash
cd SLS_Python
python -m venv .venv python -m venv .venv
source .venv/bin/activate source .venv/bin/activate
pip install -e SLS_Python
pip install -r SLS_Python/requirements-dev.txt pip install build wheel "setuptools>=61.0"
# Install the backend (one-time setup)
pip install -e sls_build_backend
# Build with --no-isolation (required because backend is local)
python -m build --no-isolation
``` ```
Run tests:
```bash
pytest -q
```
Run the REPL:
```bash
sls repl
```
Next steps (suggested)
- Port `lexer.c` to `src/sls/lexer.py` and add comprehensive tokenization tests.
- Port `parser` and `interpreter` incrementally, keeping tests for parity.
- Add CI (GitHub Actions) and type checking (`mypy`).
If you want, I can now:
- Run the tests in this environment (if you want me to configure the Python env), or
- Start porting a specific module from the C implementation (lexer is a good first target).

View File

@ -1,7 +1,7 @@
# Build this file using 'python -m build' (from 'build' package) # Build this file using 'python -m build' (from 'build' package)
[build-system] [build-system]
requires = ["setuptools>=61.0", "wheel"] requires = ["setuptools>=61.0", "wheel", "sls_build_backend"]
build-backend = "sls.build_hooks" build-backend = "sls_build_backend"
[project] [project]
name = "sls_python" name = "sls_python"

View File

@ -0,0 +1,5 @@
"""Build backend for sls_python package."""
from .build_hooks import build_wheel, build_sdist
__all__ = ["build_wheel", "build_sdist"]

View File

@ -1,10 +1,9 @@
import subprocess
from setuptools.build_meta import build_wheel as _build_wheel from setuptools.build_meta import build_wheel as _build_wheel
from setuptools.build_meta import build_sdist as _build_sdist from setuptools.build_meta import build_sdist as _build_sdist
def _generate_version(): def _generate_version():
subprocess.check_call(["python", "scripts/write_version.py"]) from .write_version import main
main()
def build_wheel(*args, **kwargs): def build_wheel(*args, **kwargs):
_generate_version() _generate_version()

View File

@ -0,0 +1,14 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "sls-build-backend"
version = "0.1.0"
description = "Build backend for sls_python"
authors = [{name = "Kyler Olsen"}]
requires-python = ">=3.10"
[tool.setuptools]
packages = ["sls_build_backend"]
package-dir = {"" = ".."}

View File

@ -3,7 +3,7 @@ import datetime
import pathlib import pathlib
root = pathlib.Path(__file__).resolve().parents[1] root = pathlib.Path(__file__).resolve().parents[1]
template = root / "scripts" / "_version.py.in" template = root / "sls_build_backend" / "_version.py.in"
output = root / "sls" / "_version.py" output = root / "sls" / "_version.py"
def get_commit(): def get_commit():