Skip to content

Commit 6c467d2

Browse files
author
github-actions[bot]
committed
Merge remote-tracking branch 'origin/master' into sync/master-into-devel
2 parents 8c59d48 + cd3f5e1 commit 6c467d2

17 files changed

Lines changed: 1695 additions & 143 deletions

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ indent_size = 4
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true
1212

13-
[*.{md,toml,yml,yaml,nix,html,css}]
13+
[{*.{md,toml,yml,yaml,nix,html,css,just},justfile}]
1414
indent_size = 2
1515

1616
[{**/Makefile,**/CMakeLists.txt}]

CMakeLists.txt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,43 +121,48 @@ add_subdirectory (3rdparty/re2 EXCLUDE_FROM_ALL)
121121
add_subdirectory (3rdparty/simlib EXCLUDE_FROM_ALL)
122122
add_subdirectory (3rdparty/cudd EXCLUDE_FROM_ALL)
123123

124-
if (MATA_BUILD_EXAMPLES)
124+
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND MATA_BUILD_EXAMPLES)
125+
message ("-- Building examples")
125126
add_subdirectory (examples)
126127
endif ()
127128

128129
# Build tests only if Mata is the main project and we enabled testing
129130
if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) AND BUILD_TESTING)
131+
message ("-- Building tests")
130132
add_subdirectory (tests)
131133
add_subdirectory (tests-integration)
132134
endif ()
133135

134136

135137
##### INSTALLING AND UNINSTALLING #####
136-
install (TARGETS libmata cudd_headers simlib_headers
137-
EXPORT mataTargets
138+
install (
139+
TARGETS libmata cudd_headers simlib_headers
140+
EXPORT mataTargets
138141
ARCHIVE DESTINATION lib
139142
)
140143
# TODO: should headers be installed in some nicer way? there is something called FILE_SET in cmake, but I do not feel it will make it better
141144
install(
142-
DIRECTORY
143-
${PROJECT_SOURCE_DIR}/include/
144-
${PROJECT_SOURCE_DIR}/3rdparty/cudd/include/ # TODO remove this after we remove PUBLIC dependency on CUDD
145-
${PROJECT_SOURCE_DIR}/3rdparty/simlib/include/ # TODO remove this after we remove PUBLIC dependency on simlib
146-
DESTINATION include
145+
DIRECTORY
146+
${PROJECT_SOURCE_DIR}/include/
147+
${PROJECT_SOURCE_DIR}/3rdparty/cudd/include/ # TODO remove this after we remove PUBLIC dependency on CUDD
148+
${PROJECT_SOURCE_DIR}/3rdparty/simlib/include/ # TODO remove this after we remove PUBLIC dependency on simlib
149+
DESTINATION include
147150
)
148-
install(EXPORT mataTargets
149-
# NAMESPACE mata:: # for modern cmake, commented out because I am not sure what could break with it
150-
DESTINATION lib/cmake/mata
151+
install(
152+
EXPORT mataTargets
153+
# NAMESPACE mata:: # for modern cmake, commented out because I am not sure what could break with it
154+
DESTINATION lib/cmake/mata
151155
)
152156

153157
include(CMakePackageConfigHelpers)
154-
configure_package_config_file(
155-
cmake/mataConfig.cmake.in # your template
156-
"${CMAKE_CURRENT_BINARY_DIR}/mataConfig.cmake" # output
157-
INSTALL_DESTINATION lib/cmake/mata
158+
configure_package_config_file(cmake/mataConfig.cmake.in
159+
"${CMAKE_CURRENT_BINARY_DIR}/mataConfig.cmake"
160+
INSTALL_DESTINATION lib/cmake/mata
161+
)
162+
install(
163+
FILES "${CMAKE_CURRENT_BINARY_DIR}/mataConfig.cmake"
164+
DESTINATION lib/cmake/mata
158165
)
159-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mataConfig.cmake"
160-
DESTINATION lib/cmake/mata)
161166

162167

163168
# Uninstall target from https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake

README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,34 @@ The Mata library further depends on the following libraries, included in the `./
4949

5050
To build the library, run the following:
5151

52-
```
52+
```shell
5353
git clone https://github.com/VeriFIT/mata
5454
cd mata
5555
make release
5656
```
5757

5858
In order to install the library, you can run
5959

60-
```
60+
```shell
6161
sudo make install
6262
```
6363

6464
In order to verify the functionality of the library, you can run the test suite:
6565

66-
```
66+
```shell
6767
make test
6868
```
6969

7070
You might, need to install the dependencies to measure the coverage of the tests.
7171
Run the following to install the dependencies for MacOS:
7272

73-
```
73+
```shell
7474
brew install lcov gcovr
7575
```
7676

7777
Run the following to install the dependencies for Ubuntu:
7878

79-
```
79+
```shell
8080
sudo apt install -y build-essential lcov gcovr xdg-utils
8181
```
8282

@@ -87,9 +87,12 @@ package on your system as follows.
8787

8888
### Installation from PyPI
8989

90-
To install a latest version from the PyPI repository, run
90+
To install a latest version from the PyPI repository, run:
9191

92-
```
92+
```shell
93+
# Using uv:
94+
uv add libmata
95+
# Or using pip:
9396
pip3 install libmata
9497
```
9598

@@ -98,7 +101,15 @@ pip3 install libmata
98101
To build from sources first, install the necessary requirements for Python and your
99102
system. We recommend using the virtual environemnt (`venv`) to install and use the library.
100103

104+
Using `uv`:
105+
106+
```shell
107+
uv sync --python 3.13
101108
```
109+
110+
Or using `pip`:
111+
112+
```shell
102113
python -m pip install --upgrade pip
103114
make -C bindings/python init
104115

@@ -108,13 +119,13 @@ sudo apt -qq install -y graphviz graphviz-dev
108119

109120
Now, you can install the library.
110121

111-
```
122+
```shell
112123
make -C bindings/python install
113124
```
114125

115126
Finally, you can verify the binding woks as expected by running the test suite:
116127

117-
```
128+
```shell
118129
make -C bindings/python test
119130
```
120131

@@ -125,21 +136,21 @@ This directory contains examples of various usage in form of:
125136

126137
1. C/C++ example programs. By default, they are built with the library. To run for example the first example:
127138

128-
```
139+
```shell
129140
./build/examples/example01-simple
130141
```
131142

132143
3. Python example scripts. To run the scripts run the following.
133144

134-
```
135-
python examples/example01-python-binding.py
145+
```shell
146+
python3 examples/example01-python-binding.py
136147
```
137148

138149
4. Python jupyter notebooks. To run the jupyter notebook, one needs to have jupyter installed as
139150
a prerequisite. The run the jupyter notebook, that creates an instance on your local server.
140151
Navigate to generated link to see the available jupyter notebooks:
141152

142-
```
153+
```shell
143154
pip3 install jupyter
144155
jupyter notebook
145156
```

bindings/python/libmata/nfa/nfa.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,17 @@ cdef class Nfa:
326326
"""
327327
self.thisptr.get().final.erase(state)
328328

329-
def clear_final(self) -> Self:
329+
def clear_final(self) -> Nfa:
330330
"""Clears final state set of the automaton."""
331331
self.thisptr.get().final.clear()
332332
return self
333333

334-
def unify_initial(self, bool force_new_state = False) -> Self:
334+
def unify_initial(self, bool force_new_state = False) -> Nfa:
335335
"""Unify initial states into a single new initial state."""
336336
self.thisptr.get().unify_initial(force_new_state)
337337
return self
338338

339-
def unify_final(self, bool force_new_state = False) -> Self:
339+
def unify_final(self, bool force_new_state = False) -> Nfa:
340340
"""Unify final states into a single new final state."""
341341
self.thisptr.get().unify_final(force_new_state)
342342

@@ -518,7 +518,7 @@ cdef class Nfa:
518518
Remove states which are not accessible (unreachable; state is accessible when the state is the endpoint of a path
519519
starting from an initial state) or not co-accessible (non-terminating; state is co-accessible when the state is
520520
the starting point of a path ending in a final state).
521-
:return: Self.
521+
:return: Nfa.
522522
"""
523523
self.thisptr.get().trim(NULL)
524524
return self
@@ -530,7 +530,7 @@ cdef class Nfa:
530530
starting from an initial state) or not co-accessible (non-terminating; state is co-accessible when the state is
531531
the starting point of a path ending in a final state).
532532
533-
:return: Self, State map of original to new states.
533+
:return: Nfa, State map of original to new states.
534534
"""
535535
cdef StateRenaming state_map
536536
self.thisptr.get().trim(&state_map)
@@ -539,15 +539,15 @@ cdef class Nfa:
539539
def concatenate(self, Nfa other) -> Nfa:
540540
"""Concatenate 'self' with 'other' in-place.
541541

542-
:return: Self
542+
:return: Nfa
543543
"""
544544
self.thisptr.get().concatenate(dereference(other.thisptr.get()))
545545
return self
546546

547547
def union(self, Nfa other) -> Nfa:
548548
"""Make union of 'self' with 'other' in-place.
549549

550-
:return: Self
550+
:return: Nfa
551551
"""
552552
self.thisptr.get().unite_nondet_with(dereference(other.thisptr.get()))
553553
return self

bindings/python/pyproject.toml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
[project]
22
name = "libmata"
33
dynamic = ["version"]
4-
description = "Mata Python bindings"
4+
description = "Python bindings for Mata: A fast and simple automata library"
55
readme = "README.md"
66
requires-python = ">=3.13"
7+
keywords = ["automata", "finite automata", "alternating automata"]
8+
authors = [
9+
{ name = "Lukáš Holík", email = "holik@fit.vutbr.cz" },
10+
{ name = "Ondřej Lengál", email = "lengal@fit.vutbr.cz" },
11+
{ name = "Martin Hruška", email = "ihruskam@fit.vutbr.cz" },
12+
{ name = "Tomáš Fiedor", email = "ifiedortom@fit.vutbr.cz" },
13+
{ name = "David Chocholatý", email = "chocholaty.david@protonmail.com" },
14+
{ name = "Juraj Síč", email = "sicjuraj@fit.vutbr.cz" },
15+
{ name = "Tomáš Vojnar", email = "vojnar@fit.vutbr.cz" },
16+
]
717
dependencies = [
818
"coverage>=6.4.1",
919
"cython>=0.29.32",
10-
"graphviz>=0.20.0",
11-
"ipykernel>=7.2.0",
20+
"graphviz>=0.20.1",
21+
"ipykernel>=7.1.0",
1222
"ipython>=7.9.0",
1323
"networkx>=2.6.3",
1424
"pandas>=1.3.5",
15-
"papermill>=2.7.0",
25+
"papermill>=2.6.0",
1626
"pytest>=3.6.4",
1727
"pytest-cov>=3.0.0",
1828
"seaborn>=0.13.2",
19-
"setuptools>=82.0.1",
2029
"tabulate>=0.8.10",
2130
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/VeriFIT/mata"
34+
35+
[tool.setuptools]
36+
packages = ["libmata", "libmata.nfa"]
37+
2238
[build-system]
2339
requires = ["setuptools", "wheel", "Cython>=0.29.32"]
2440
build-backend = "setuptools.build_meta"

bindings/python/setup.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -249,38 +249,7 @@ def run_safely_external_command(
249249

250250

251251
setup(
252-
name="libmata",
253-
packages=["libmata", "libmata.nfa"],
254-
package_dir={'libmata': 'libmata', 'libmata.nfa': os.path.join('libmata', 'nfa')},
255252
version=get_version(),
256-
ext_modules=cythonize(
257-
extensions,
258-
compiler_directives={'language_level': "3"}
259-
),
260-
description="The automata library",
261-
author="Lukáš Holík <holik@fit.vutbr.cz>, "
262-
"Ondřej Lengál <lengal@fit.vutbr.cz>, "
263-
"Martin Hruška <ihruskam@fit.vutbr.cz>, "
264-
"Tomáš Fiedor <ifiedortom@fit.vutbr.cz>, "
265-
"David Chocholatý <chocholaty.david@protonmail.com>, "
266-
"Juraj Síč <sicjuraj@fit.vutbr.cz>, "
267-
"Tomáš Vojnar <vojnar@fit.vutbr.cz>",
268-
author_email="holik@fit.vutbr.cz",
269-
long_description=README_MD,
270-
long_description_content_type="text/markdown",
271-
keywords="automata, finite automata, alternating automata",
272-
url="https://github.com/verifit/mata",
273-
cmdclass={
274-
'sdist': sdist,
275-
'build_ext': build_ext
276-
},
277-
# Requirements from install for pip
278-
install_requires=[
279-
'Cython>=0.29.32',
280-
'tabulate>=0.8.10',
281-
'ipython>=7.9.0',
282-
'pandas>=1.3.5',
283-
'networkx>=2.6.3',
284-
'graphviz>=0.10.1',
285-
]
253+
ext_modules=cythonize(extensions, compiler_directives={"language_level": "3"}),
254+
cmdclass={"sdist": sdist, "build_ext": build_ext},
286255
)

examples/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
file(GLOB MATA_EXAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
1+
file(GLOB_RECURSE MATA_EXAMPLES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
22
foreach(MATA_EXAMPLE ${MATA_EXAMPLES})
3-
get_filename_component(MATA_EXAMPLE_NAME ${MATA_EXAMPLE} NAME_WE)
4-
add_executable(${MATA_EXAMPLE_NAME} ${MATA_EXAMPLE})
5-
target_link_libraries(${MATA_EXAMPLE_NAME} PRIVATE libmata)
6-
endforeach()
3+
file(RELATIVE_PATH MATA_EXAMPLE_REL "${CMAKE_CURRENT_SOURCE_DIR}" "${MATA_EXAMPLE}")
4+
string(REPLACE "/" "-" MATA_EXAMPLE_NAME "${MATA_EXAMPLE_REL}")
5+
string(REPLACE ".cc" "" MATA_EXAMPLE_NAME "${MATA_EXAMPLE_NAME}")
6+
add_executable(${MATA_EXAMPLE_NAME} ${MATA_EXAMPLE})
7+
target_link_libraries(${MATA_EXAMPLE_NAME} PRIVATE libmata)
8+
endforeach()

examples/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Makefile wrapper for building/running selected MATA examples via CMake.
2+
3+
ROOT_DIR ?= ..
4+
BUILD_DIR ?= $(ROOT_DIR)/build
5+
CMAKE_BUILD_TYPE ?= Debug
6+
JOBS ?= 6
7+
8+
EXAMPLE ?= example01-simple
9+
10+
.PHONY: all configure build run clean
11+
12+
all: build
13+
14+
configure:
15+
cmake -S $(ROOT_DIR) -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
16+
17+
build: configure
18+
cmake --build $(BUILD_DIR) --parallel $(JOBS)
19+
20+
run: build
21+
$(BUILD_DIR)/examples/$(EXAMPLE)
22+
23+
clean:
24+
rm -f $(BUILD_DIR)/examples/$(EXAMPLE)

examples/notebooks/jupytext.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
formats = "ipynb,py:percent"
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
set -euo pipefail
44

5-
papermill ./example-01-ws1s-formulae.ipynb tmp_out.ipynb
6-
papermill ./example-02-redos-attacks.ipynb tmp_out.ipynb
7-
papermill ./example-03-exploring-maze.ipynb tmp_out.ipynb
8-
papermill ./example-04-visualization.ipynb tmp_out.ipynb
9-
rm tmp_out.ipynb
5+
SCRIPT_DIR="$(dirname "$0")"
6+
7+
TMP_OUT="$(mktemp --tmpdir mata-papermill-XXXXXX.ipynb)"
8+
trap 'rm -f "$TMP_OUT"' EXIT
9+
10+
for file in "$SCRIPT_DIR"/*.ipynb; do
11+
echo "Running: $file."
12+
papermill "$file" "$TMP_OUT"
13+
done

0 commit comments

Comments
 (0)