Created sls_build_backend module to help build the python module
This commit is contained in:
parent
3c288e9165
commit
c1db0937a2
|
|
@ -1,2 +0,0 @@
|
|||
include scripts/*.py
|
||||
include scripts/*.in
|
||||
|
|
@ -1,42 +1,17 @@
|
|||
# SLS Python
|
||||
|
||||
This directory contains a minimal Python project skeleton intended to reimplement
|
||||
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:
|
||||
## Building
|
||||
|
||||
```bash
|
||||
cd SLS_Python
|
||||
python -m venv .venv
|
||||
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).
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Build this file using 'python -m build' (from 'build' package)
|
||||
[build-system]
|
||||
requires = ["setuptools>=61.0", "wheel"]
|
||||
build-backend = "sls.build_hooks"
|
||||
requires = ["setuptools>=61.0", "wheel", "sls_build_backend"]
|
||||
build-backend = "sls_build_backend"
|
||||
|
||||
[project]
|
||||
name = "sls_python"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
"""Build backend for sls_python package."""
|
||||
|
||||
from .build_hooks import build_wheel, build_sdist
|
||||
|
||||
__all__ = ["build_wheel", "build_sdist"]
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
import subprocess
|
||||
from setuptools.build_meta import build_wheel as _build_wheel
|
||||
from setuptools.build_meta import build_sdist as _build_sdist
|
||||
|
||||
def _generate_version():
|
||||
subprocess.check_call(["python", "scripts/write_version.py"])
|
||||
|
||||
from .write_version import main
|
||||
main()
|
||||
|
||||
def build_wheel(*args, **kwargs):
|
||||
_generate_version()
|
||||
|
|
@ -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 = {"" = ".."}
|
||||
|
|
@ -3,7 +3,7 @@ import datetime
|
|||
import pathlib
|
||||
|
||||
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"
|
||||
|
||||
def get_commit():
|
||||
Loading…
Reference in New Issue