chiklisp-builder 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chiklisp_builder-0.1.2/LICENSE +13 -0
- chiklisp_builder-0.1.2/PKG-INFO +37 -0
- chiklisp_builder-0.1.2/README.md +15 -0
- chiklisp_builder-0.1.2/chiklisp_builder.egg-info/PKG-INFO +37 -0
- chiklisp_builder-0.1.2/chiklisp_builder.egg-info/SOURCES.txt +14 -0
- chiklisp_builder-0.1.2/chiklisp_builder.egg-info/dependency_links.txt +1 -0
- chiklisp_builder-0.1.2/chiklisp_builder.egg-info/requires.txt +2 -0
- chiklisp_builder-0.1.2/chiklisp_builder.egg-info/top_level.txt +1 -0
- chiklisp_builder-0.1.2/chiklisp_builder.py +61 -0
- chiklisp_builder-0.1.2/pyproject.toml +12 -0
- chiklisp_builder-0.1.2/setup.cfg +4 -0
- chiklisp_builder-0.1.2/setup.py +5 -0
- chiklisp_builder-0.1.2/tests/a.clib +4 -0
- chiklisp_builder-0.1.2/tests/b.clib +3 -0
- chiklisp_builder-0.1.2/tests/mod.clsp +4 -0
- chiklisp_builder-0.1.2/tests/test_chiklisp_build.py +47 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 by Richard Kiss
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: chiklisp_builder
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Allow on-demand builds of chiklisp with recursive dependency checking.
|
|
5
|
+
Author-email: Richard Kiss <him@richardkiss.com>
|
|
6
|
+
License: Copyright 2023 by Richard Kiss
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# Chiklisp Builder
|
|
24
|
+
|
|
25
|
+
Use this wheel in conjunction with `runtime_builder` to manage building of chiklisp at build time or during development.
|
|
26
|
+
|
|
27
|
+
# Use
|
|
28
|
+
|
|
29
|
+
Add `chiklisp_builder` as a buildtime dependency and a development-time dependency. Don't add it as a runtime dependency, as the klvm `.hex` files should be built and included with the wheel. The source does not need to be.
|
|
30
|
+
|
|
31
|
+
Add `chiklisp_loader` as a runtime dependency to get the `load_program` function, which will call the building function if present (as it should be at development time.)
|
|
32
|
+
|
|
33
|
+
# FAQ
|
|
34
|
+
|
|
35
|
+
Why isn't this included as part of `runtime_builder`?
|
|
36
|
+
|
|
37
|
+
The `runtime_builder` wheel is intended to provide a general solution for non-python artifacts. Although Chiklisp build was the inspiration for `runtime_builder`, it's just one potential use. This wheel is the specific implementation of chiklisp builds for use with `runtime_builder`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Chiklisp Builder
|
|
2
|
+
|
|
3
|
+
Use this wheel in conjunction with `runtime_builder` to manage building of chiklisp at build time or during development.
|
|
4
|
+
|
|
5
|
+
# Use
|
|
6
|
+
|
|
7
|
+
Add `chiklisp_builder` as a buildtime dependency and a development-time dependency. Don't add it as a runtime dependency, as the klvm `.hex` files should be built and included with the wheel. The source does not need to be.
|
|
8
|
+
|
|
9
|
+
Add `chiklisp_loader` as a runtime dependency to get the `load_program` function, which will call the building function if present (as it should be at development time.)
|
|
10
|
+
|
|
11
|
+
# FAQ
|
|
12
|
+
|
|
13
|
+
Why isn't this included as part of `runtime_builder`?
|
|
14
|
+
|
|
15
|
+
The `runtime_builder` wheel is intended to provide a general solution for non-python artifacts. Although Chiklisp build was the inspiration for `runtime_builder`, it's just one potential use. This wheel is the specific implementation of chiklisp builds for use with `runtime_builder`.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: chiklisp-builder
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Allow on-demand builds of chiklisp with recursive dependency checking.
|
|
5
|
+
Author-email: Richard Kiss <him@richardkiss.com>
|
|
6
|
+
License: Copyright 2023 by Richard Kiss
|
|
7
|
+
|
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
you may not use this file except in compliance with the License.
|
|
10
|
+
You may obtain a copy of the License at
|
|
11
|
+
|
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
|
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
See the License for the specific language governing permissions and
|
|
18
|
+
limitations under the License.
|
|
19
|
+
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
|
|
23
|
+
# Chiklisp Builder
|
|
24
|
+
|
|
25
|
+
Use this wheel in conjunction with `runtime_builder` to manage building of chiklisp at build time or during development.
|
|
26
|
+
|
|
27
|
+
# Use
|
|
28
|
+
|
|
29
|
+
Add `chiklisp_builder` as a buildtime dependency and a development-time dependency. Don't add it as a runtime dependency, as the klvm `.hex` files should be built and included with the wheel. The source does not need to be.
|
|
30
|
+
|
|
31
|
+
Add `chiklisp_loader` as a runtime dependency to get the `load_program` function, which will call the building function if present (as it should be at development time.)
|
|
32
|
+
|
|
33
|
+
# FAQ
|
|
34
|
+
|
|
35
|
+
Why isn't this included as part of `runtime_builder`?
|
|
36
|
+
|
|
37
|
+
The `runtime_builder` wheel is intended to provide a general solution for non-python artifacts. Although Chiklisp build was the inspiration for `runtime_builder`, it's just one potential use. This wheel is the specific implementation of chiklisp builds for use with `runtime_builder`.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
chiklisp_builder.py
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
chiklisp_builder.egg-info/PKG-INFO
|
|
7
|
+
chiklisp_builder.egg-info/SOURCES.txt
|
|
8
|
+
chiklisp_builder.egg-info/dependency_links.txt
|
|
9
|
+
chiklisp_builder.egg-info/requires.txt
|
|
10
|
+
chiklisp_builder.egg-info/top_level.txt
|
|
11
|
+
tests/a.clib
|
|
12
|
+
tests/b.clib
|
|
13
|
+
tests/mod.clsp
|
|
14
|
+
tests/test_chiklisp_build.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
chiklisp_builder
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import List
|
|
3
|
+
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
import klvm_tools_rs
|
|
7
|
+
|
|
8
|
+
CRE = re.compile(r"\((\s)*include(\s)+(.+)\)")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def find_included_items(item: Path) -> List[Path]:
|
|
12
|
+
contents = item.read_text()
|
|
13
|
+
matches = CRE.findall(contents)
|
|
14
|
+
included = []
|
|
15
|
+
for match in matches:
|
|
16
|
+
s = match[-1]
|
|
17
|
+
if len(s) > 1 and s[0] == s[-1] and s[0] in "'\"":
|
|
18
|
+
included.append(s[1:-1])
|
|
19
|
+
else:
|
|
20
|
+
included.append(s)
|
|
21
|
+
return included
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def calculate_dependencies(source_path: Path, include_paths: List[Path]) -> List[Path]:
|
|
25
|
+
include_paths = [Path(_) for _ in include_paths]
|
|
26
|
+
dependencies = set()
|
|
27
|
+
to_check = [source_path]
|
|
28
|
+
while len(to_check):
|
|
29
|
+
item = to_check.pop()
|
|
30
|
+
if item in dependencies:
|
|
31
|
+
continue
|
|
32
|
+
dependencies.add(item)
|
|
33
|
+
included_items = find_included_items(item)
|
|
34
|
+
for include_item in included_items:
|
|
35
|
+
for include_path in include_paths:
|
|
36
|
+
p = include_path / include_item
|
|
37
|
+
if p.exists():
|
|
38
|
+
to_check.append(p)
|
|
39
|
+
return dependencies
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ChiklispBuild:
|
|
43
|
+
def __init__(self, include_paths: List[Path] = []):
|
|
44
|
+
self.include_paths = include_paths
|
|
45
|
+
self.include_paths_as_str = [str(_) for _ in include_paths]
|
|
46
|
+
|
|
47
|
+
def __call__(self, target_path: Path):
|
|
48
|
+
source_path = target_path.with_suffix(".clsp")
|
|
49
|
+
|
|
50
|
+
dependencies = calculate_dependencies(source_path, self.include_paths)
|
|
51
|
+
latest_date = max(_.stat().st_mtime for _ in dependencies)
|
|
52
|
+
|
|
53
|
+
if not target_path.exists() or target_path.stat().st_mtime < latest_date:
|
|
54
|
+
# we need to rebuild
|
|
55
|
+
if target_path.exists():
|
|
56
|
+
# `compile_klvm` doesn't always replace existing files as of 0.1.34
|
|
57
|
+
target_path.unlink()
|
|
58
|
+
source_path_str, target_path_str = str(source_path), str(target_path)
|
|
59
|
+
klvm_tools_rs.compile_klvm(
|
|
60
|
+
source_path_str, target_path_str, self.include_paths_as_str
|
|
61
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "chiklisp_builder"
|
|
3
|
+
description = "Allow on-demand builds of chiklisp with recursive dependency checking."
|
|
4
|
+
authors = [{name = "Richard Kiss", email = "him@richardkiss.com"}]
|
|
5
|
+
license = {file = "LICENSE"}
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
dependencies = ["klvm_tools_rs", "runtime_builder >= 0.1.3"]
|
|
9
|
+
|
|
10
|
+
[build-system]
|
|
11
|
+
requires = ["setuptools>=42", "wheel"]
|
|
12
|
+
build-backend = "setuptools.build_meta"
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
import tempfile
|
|
5
|
+
|
|
6
|
+
from chiklisp_builder import ChiklispBuild
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_chiklisp_build():
|
|
10
|
+
here = Path(__file__).parent
|
|
11
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
12
|
+
tmpdir = Path(tmpdir)
|
|
13
|
+
|
|
14
|
+
# copy files to temporary directory
|
|
15
|
+
shutil.copytree(here, tmpdir, dirs_exist_ok=True)
|
|
16
|
+
|
|
17
|
+
# create builder
|
|
18
|
+
_mod_file = tmpdir / "mod.clsp"
|
|
19
|
+
artifact_f = ChiklispBuild(include_paths=[tmpdir])
|
|
20
|
+
target_path = tmpdir / "mod.hex"
|
|
21
|
+
|
|
22
|
+
artifact_f(target_path)
|
|
23
|
+
output = target_path.read_text()
|
|
24
|
+
assert output == "ff10ff02ffff0182012c80\n"
|
|
25
|
+
|
|
26
|
+
# change `b.clib`
|
|
27
|
+
blib = tmpdir / "b.clib"
|
|
28
|
+
blib.write_text("((defconstant CONST_B 400))")
|
|
29
|
+
|
|
30
|
+
artifact_f(target_path)
|
|
31
|
+
output = target_path.read_text()
|
|
32
|
+
assert output == "ff10ff02ffff018201f480\n"
|
|
33
|
+
|
|
34
|
+
# change `b.clib` but rewrite target file so we trick `ChiklispBuild` into not rebuilding
|
|
35
|
+
blib.write_text("((defconstant CONST_B 500))")
|
|
36
|
+
target_path.write_text(output)
|
|
37
|
+
|
|
38
|
+
artifact_f(target_path)
|
|
39
|
+
output = target_path.read_text()
|
|
40
|
+
assert output == "ff10ff02ffff018201f480\n"
|
|
41
|
+
|
|
42
|
+
# touch `b.clib` and try again
|
|
43
|
+
blib.write_text("((defconstant CONST_B 500))")
|
|
44
|
+
|
|
45
|
+
artifact_f(target_path)
|
|
46
|
+
output = target_path.read_text()
|
|
47
|
+
assert output == "ff10ff02ffff0182025880\n"
|