Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Commit 33c63dc

Browse files
Merge pull request #47 from Chia-Network/20220718-export-sym
Add a 4th argument to compile_clvm to produce complex output
2 parents 552942f + e90f503 commit 33c63dc

File tree

7 files changed

+27
-14
lines changed

7 files changed

+27
-14
lines changed

.github/workflows/build-arm64-wheels.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
/opt/python/cp38-cp38/bin/python -m venv venv && \
5252
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \
5353
. ./activate && \
54-
pip install maturin && \
55-
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 \
56-
--cargo-extra-args="--all-features" \
54+
pip install maturin==0.12.20 && \
55+
CC=gcc maturin build --release --strip --manylinux 2014 \
56+
--no-sdist --cargo-extra-args=--all-features \
5757
'
5858
5959
- name: Upload artifacts

.github/workflows/build-m1-wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
arch -arm64 python3 -m venv venv
4343
. ./venv/bin/activate
4444
export PATH=~/.cargo/bin:$PATH
45-
arch -arm64 pip install maturin
45+
arch -arm64 pip install maturin==0.12.20
4646
arch -arm64 maturin build --no-sdist -i python --release --strip --cargo-extra-args="--all-features"
4747
arch -arm64 cargo test --no-default-features
4848

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
- name: Install dependencies
4545
run: |
46-
python -m pip install maturin
46+
python -m pip install maturin==0.12.20
4747
4848
- name: Build MacOs with maturin on Python ${{ matrix.python }}
4949
if: startsWith(matrix.os, 'macos')
@@ -78,7 +78,7 @@ jobs:
7878
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \
7979
. ./activate && \
8080
pip install --upgrade pip && \
81-
pip install maturin && \
81+
pip install maturin==0.12.20 && \
8282
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 \
8383
'
8484

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clvm_tools_rs"
3-
version = "0.1.19"
3+
version = "0.1.20"
44
edition = "2018"
55
authors = ["Art Yerkes <[email protected]>"]
66
description = "tools for working with chialisp language; compiler, repl, python and wasm bindings"

src/classic/clvm_tools/clvmc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ pub fn compile_clvm(
131131
input_path: &String,
132132
output_path: &String,
133133
search_paths: &Vec<String>,
134+
symbol_table: &mut HashMap<String, String>,
134135
) -> Result<String, String> {
135136
let mut allocator = Allocator::new();
136137

137138
let compile = newer(input_path, output_path).unwrap_or_else(|_| true);
138-
let mut symbol_table = HashMap::new();
139139
let mut result_stream = Stream::new(None);
140140

141141
if compile {
@@ -145,7 +145,7 @@ pub fn compile_clvm(
145145
let _ = compile_clvm_inner(
146146
&mut allocator,
147147
search_paths,
148-
&mut symbol_table,
148+
symbol_table,
149149
input_path,
150150
&text,
151151
&mut result_stream,

src/py/api.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ fn get_version() -> PyResult<String> {
3333
Ok(env!("CARGO_PKG_VERSION").to_string())
3434
}
3535

36-
#[pyfunction(arg3 = "[]")]
36+
#[pyfunction(arg3 = "[]", arg4 = "None")]
3737
fn compile_clvm(
3838
input_path: &PyAny,
3939
output_path: String,
4040
search_paths: Vec<String>,
41-
) -> PyResult<String> {
41+
export_symbols: Option<bool>,
42+
) -> PyResult<PyObject> {
4243
let has_atom = input_path.hasattr("atom")?;
4344
let has_pair = input_path.hasattr("pair")?;
4445

@@ -59,8 +60,20 @@ fn compile_clvm(
5960
path_string = path_string + ".clvm";
6061
};
6162

62-
clvmc::compile_clvm(&path_string, &output_path, &search_paths)
63-
.map_err(|s| PyException::new_err(s))
63+
let mut symbols = HashMap::new();
64+
let compiled = clvmc::compile_clvm(&path_string, &output_path, &search_paths, &mut symbols)
65+
.map_err(|s| PyException::new_err(s))?;
66+
67+
Python::with_gil(|py| {
68+
if export_symbols == Some(true) {
69+
let mut result_dict = HashMap::new();
70+
result_dict.insert("output".to_string(), compiled.into_py(py));
71+
result_dict.insert("symbols".to_string(), symbols.into_py(py));
72+
Ok(result_dict.into_py(py))
73+
} else {
74+
Ok(compiled.into_py(py))
75+
}
76+
})
6477
}
6578

6679
#[pyclass]

0 commit comments

Comments
 (0)