mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-31 07:38:02 +00:00
feat: make erg_compiler
available as a Python lib
This commit is contained in:
parent
22ccf4d870
commit
8b17c6cf6c
9 changed files with 152 additions and 4 deletions
|
@ -19,6 +19,7 @@ pretty = ["erg_common/pretty"]
|
|||
large_thread = ["erg_common/large_thread"]
|
||||
experimental = ["erg_common/experimental"]
|
||||
pylib = ["dep:pyo3", "erg_common/pylib"]
|
||||
pylib_parser = ["pylib"]
|
||||
|
||||
[dependencies]
|
||||
erg_common = { workspace = true }
|
||||
|
|
|
@ -15,8 +15,17 @@ for chunk in module:
|
|||
assert chunk.sig.inspect() == "x"
|
||||
```
|
||||
|
||||
### Debug install
|
||||
### Debug install (using venv)
|
||||
|
||||
```python
|
||||
maturin develop --features pylib
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate
|
||||
maturin develop --features pylib_parser
|
||||
```
|
||||
|
||||
### Release install
|
||||
|
||||
```python
|
||||
maturin build -i python --release --features pylib_parser
|
||||
pip install <output wheel>
|
||||
```
|
||||
|
|
|
@ -30,7 +30,7 @@ fn _parse(code: String) -> Result<ast::Module, error::ParseErrors> {
|
|||
.map_err(|iart| iart.errors)
|
||||
}
|
||||
|
||||
#[cfg(feature = "pylib")]
|
||||
#[cfg(feature = "pylib_parser")]
|
||||
#[pymodule]
|
||||
fn erg_parser(py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(_parse, m)?)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue