Compare commits
2 Commits
3c288e9165
...
ac9bbc0415
| Author | SHA1 | Date |
|---|---|---|
|
|
ac9bbc0415 | |
|
|
c1db0937a2 |
|
|
@ -1,2 +0,0 @@
|
||||||
include scripts/*.py
|
|
||||||
include scripts/*.in
|
|
||||||
|
|
@ -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).
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Build this file using 'python -m build' (from 'build' package)
|
# Build this file using 'python -m build --no-isolation'
|
||||||
[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"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
"""Build backend for sls_python package."""
|
||||||
|
|
||||||
|
from .build_hooks import build_wheel, build_sdist
|
||||||
|
|
||||||
|
__all__ = ["build_wheel", "build_sdist"]
|
||||||
|
|
@ -1,16 +1,19 @@
|
||||||
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():
|
||||||
subprocess.check_call(["python", "scripts/write_version.py"])
|
main()
|
||||||
|
|
||||||
|
|
||||||
def build_wheel(*args, **kwargs):
|
def build_wheel(*args, **kwargs):
|
||||||
_generate_version()
|
_generate_version()
|
||||||
return _build_wheel(*args, **kwargs)
|
o = _build_wheel(*args, **kwargs)
|
||||||
|
clean_output()
|
||||||
|
return o
|
||||||
|
|
||||||
|
|
||||||
def build_sdist(*args, **kwargs):
|
def build_sdist(*args, **kwargs):
|
||||||
_generate_version()
|
_generate_version()
|
||||||
return _build_sdist(*args, **kwargs)
|
o = _build_sdist(*args, **kwargs)
|
||||||
|
clean_output()
|
||||||
|
return o
|
||||||
|
|
@ -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
|
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():
|
||||||
|
|
@ -27,6 +27,10 @@ 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()
|
||||||
Loading…
Reference in New Issue