Compare commits
No commits in common. "ac9bbc041550120f0212a8e71e62a683256d4ff2" and "3c288e916555baf0fbf9fe23c9b3fbc0f1bbf78e" have entirely different histories.
ac9bbc0415
...
3c288e9165
|
|
@ -0,0 +1,2 @@
|
||||||
|
include scripts/*.py
|
||||||
|
include scripts/*.in
|
||||||
|
|
@ -1,17 +1,42 @@
|
||||||
# SLS Python
|
# SLS Python
|
||||||
|
|
||||||
## Building
|
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:
|
||||||
|
|
||||||
```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 build wheel "setuptools>=61.0"
|
pip install -r SLS_Python/requirements-dev.txt
|
||||||
|
|
||||||
# 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 --no-isolation'
|
# Build this file using 'python -m build' (from 'build' package)
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["setuptools>=61.0", "wheel", "sls_build_backend"]
|
requires = ["setuptools>=61.0", "wheel"]
|
||||||
build-backend = "sls_build_backend"
|
build-backend = "sls.build_hooks"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "sls_python"
|
name = "sls_python"
|
||||||
|
|
|
||||||
|
|
@ -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 / "sls_build_backend" / "_version.py.in"
|
template = root / "scripts" / "_version.py.in"
|
||||||
output = root / "sls" / "_version.py"
|
output = root / "sls" / "_version.py"
|
||||||
|
|
||||||
def get_commit():
|
def get_commit():
|
||||||
|
|
@ -27,10 +27,6 @@ def get_commit():
|
||||||
def get_timestamp():
|
def get_timestamp():
|
||||||
return datetime.datetime.now(datetime.timezone.utc).isoformat() + "Z"
|
return datetime.datetime.now(datetime.timezone.utc).isoformat() + "Z"
|
||||||
|
|
||||||
def clean_output():
|
|
||||||
if output.exists():
|
|
||||||
output.unlink()
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
commit = get_commit()
|
commit = get_commit()
|
||||||
timestamp = get_timestamp()
|
timestamp = get_timestamp()
|
||||||
|
|
@ -1,19 +1,16 @@
|
||||||
|
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
|
||||||
from .write_version import main, clean_output
|
|
||||||
|
|
||||||
def _generate_version():
|
def _generate_version():
|
||||||
main()
|
subprocess.check_call(["python", "scripts/write_version.py"])
|
||||||
|
|
||||||
|
|
||||||
def build_wheel(*args, **kwargs):
|
def build_wheel(*args, **kwargs):
|
||||||
_generate_version()
|
_generate_version()
|
||||||
o = _build_wheel(*args, **kwargs)
|
return _build_wheel(*args, **kwargs)
|
||||||
clean_output()
|
|
||||||
return o
|
|
||||||
|
|
||||||
|
|
||||||
def build_sdist(*args, **kwargs):
|
def build_sdist(*args, **kwargs):
|
||||||
_generate_version()
|
_generate_version()
|
||||||
o = _build_sdist(*args, **kwargs)
|
return _build_sdist(*args, **kwargs)
|
||||||
clean_output()
|
|
||||||
return o
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
"""Build backend for sls_python package."""
|
|
||||||
|
|
||||||
from .build_hooks import build_wheel, build_sdist
|
|
||||||
|
|
||||||
__all__ = ["build_wheel", "build_sdist"]
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
[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 = {"" = ".."}
|
|
||||||
Loading…
Reference in New Issue