mirror of https://github.com/mamba-org/mamba.git
parent
51fdd6d894
commit
d839af71d1
|
@ -201,6 +201,11 @@ jobs:
|
|||
run: |
|
||||
micromamba activate build_env
|
||||
pip install -e ./libmambapy/ --no-deps
|
||||
- name: check libmambapy stubs
|
||||
shell: bash -l {0}
|
||||
run: |
|
||||
pybind11-stubgen libmambapy.bindings
|
||||
python compare_stubs.py libmambapy/libmambapy/__init__.pyi stubs/libmambapy/bindings-stubs/__init__.pyi
|
||||
- name: build cache statistics
|
||||
run: sccache --show-stats
|
||||
- name: install mamba
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import ast
|
||||
import sys
|
||||
from itertools import zip_longest
|
||||
|
||||
|
||||
# https://stackoverflow.com/a/66733795
|
||||
# original autho Seanny123, CC BY-SA 4.0
|
||||
def compare_ast(node1, node2) -> bool:
|
||||
if type(node1) is not type(node2):
|
||||
return False
|
||||
|
||||
if isinstance(node1, ast.AST):
|
||||
for k, v in vars(node1).items():
|
||||
if k in {"lineno", "end_lineno", "col_offset", "end_col_offset", "ctx"}:
|
||||
continue
|
||||
if not compare_ast(v, getattr(node2, k)):
|
||||
return False
|
||||
return True
|
||||
|
||||
elif isinstance(node1, list) and isinstance(node2, list):
|
||||
return all(compare_ast(n1, n2) for n1, n2 in zip_longest(node1, node2))
|
||||
else:
|
||||
return node1 == node2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(sys.argv)
|
||||
|
||||
f1, f2 = sys.argv[1:3]
|
||||
|
||||
with open(f1) as fi:
|
||||
a1 = ast.parse(fi.read())
|
||||
|
||||
with open(f2) as fi:
|
||||
a2 = ast.parse(fi.read())
|
||||
|
||||
if not compare_ast(a1, a2):
|
||||
print("Stubs are different! Please rerun pybind11-stubgen")
|
||||
print("CI has these: \n\n")
|
||||
with open(f2) as fi:
|
||||
print(fi.read())
|
||||
sys.exit(1)
|
|
@ -19,5 +19,6 @@ dependencies:
|
|||
- cli11 >=2.2
|
||||
- spdlog
|
||||
- pybind11
|
||||
- pybind11-stubgen
|
||||
- pytest
|
||||
- sel(win): winreg
|
||||
|
|
|
@ -19,6 +19,7 @@ dependencies:
|
|||
- cli11 >=2.2
|
||||
- spdlog
|
||||
- pybind11
|
||||
- pybind11-stubgen
|
||||
- pytest
|
||||
- conda
|
||||
- sel(win): winreg
|
||||
|
|
Loading…
Reference in New Issue