diff --git a/README.md b/README.md index c9b5ce1..bc1b469 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ where `` is the directory where you cloned the `PyTeLo` repository. Install *Gurobi* with *gurobipy* for python3. - Run --- @@ -59,6 +58,17 @@ BibTeX: } ``` +Install as Package +--- +After running `antlr4` above, from one directory level above `pytelo/` + +```bash +pip install pytelo/ +``` + +This will let other packages import pytelo functions without including pytelo in their directory structure or referencing the associated files by location. + + **NOTE:** At the moment the implementation only supports python2 and python3. However, you can generate lexers, parsers, listners, and visitors for other target languages, such as Java (default), C++, C#, Go, JavaScript, and Swift. diff --git a/mtl/__init__.py b/mtl/__init__.py deleted file mode 100644 index 02886ea..0000000 --- a/mtl/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from mtlLexer import mtlLexer -from mtlParser import mtlParser -from mtl import MTLAbstractSyntaxTreeExtractor -from mtl import Operation, RelOperation, MTLFormula \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..cf977c0 --- /dev/null +++ b/setup.py @@ -0,0 +1,26 @@ +from setuptools import find_packages, setup + +DISTNAME = "PyTeLo" + +DESCRIPTION = "A Flexible and Efficient Temporal Logic Tool for Python" + +INSTALL_REQUIRES = ["antlr4-python3-runtime==4.13.0", + "scipy", + "gurobipy"] + +setup( + name=DISTNAME, + author="ERL Lehigh", + version="0.1.0", + description=DESCRIPTION, + url="https://github.com/erl-lehigh/PyTeLo", + python_requires=">=3.6, <3.11", + package_dir={"": "src"}, + packages=find_packages("src"), + include_package_data=True, + install_requires=INSTALL_REQUIRES, + # extras_require=EXTRAS_REQUIRES, +) + +# to install: +# pip install . diff --git a/src/pytelo/__init__.py b/src/pytelo/__init__.py new file mode 100644 index 0000000..66498a6 --- /dev/null +++ b/src/pytelo/__init__.py @@ -0,0 +1,5 @@ +from .stl import STLFormula, Trace, TraceBatch +from .mtl import MTLFormula + + +__version__ = "0.1.0" diff --git a/src/pytelo/mtl/__init__.py b/src/pytelo/mtl/__init__.py new file mode 100644 index 0000000..6ba9f6c --- /dev/null +++ b/src/pytelo/mtl/__init__.py @@ -0,0 +1,5 @@ +from .mtlLexer import mtlLexer +from .mtlParser import mtlParser +from .mtl import MTLAbstractSyntaxTreeExtractor +from .mtl import Operation, MTLFormula +from .mtl import to_ast diff --git a/mtl/mtl.g4 b/src/pytelo/mtl/mtl.g4 similarity index 100% rename from mtl/mtl.g4 rename to src/pytelo/mtl/mtl.g4 diff --git a/mtl/mtl.py b/src/pytelo/mtl/mtl.py similarity index 98% rename from mtl/mtl.py rename to src/pytelo/mtl/mtl.py index ddb6b15..044261a 100644 --- a/mtl/mtl.py +++ b/src/pytelo/mtl/mtl.py @@ -6,9 +6,9 @@ from antlr4 import InputStream, CommonTokenStream -from mtlLexer import mtlLexer -from mtlParser import mtlParser -from mtlVisitor import mtlVisitor +from .mtlLexer import mtlLexer +from .mtlParser import mtlParser +from .mtlVisitor import mtlVisitor class Operation(object): diff --git a/mtl/mtl2milp.py b/src/pytelo/mtl/mtl2milp.py similarity index 98% rename from mtl/mtl2milp.py rename to src/pytelo/mtl/mtl2milp.py index 8cd2ceb..ac57025 100644 --- a/mtl/mtl2milp.py +++ b/src/pytelo/mtl/mtl2milp.py @@ -6,7 +6,7 @@ import gurobipy as grb -from mtl import Operation, MTLFormula +from .mtl import Operation, MTLFormula class mtl2milp(object): @@ -146,4 +146,4 @@ def until(self, formula, z, t): + sum(z_children_left[:t+a+k+1])) self.model.addConstr(z >= z_conj) - self.model.addConstr(z <= sum(z_aux)) \ No newline at end of file + self.model.addConstr(z <= sum(z_aux)) diff --git a/mtl/test/mtl2milp_test.py b/src/pytelo/mtl/test/mtl2milp_test.py similarity index 100% rename from mtl/test/mtl2milp_test.py rename to src/pytelo/mtl/test/mtl2milp_test.py diff --git a/src/pytelo/stl/__init__.py b/src/pytelo/stl/__init__.py new file mode 100644 index 0000000..9026730 --- /dev/null +++ b/src/pytelo/stl/__init__.py @@ -0,0 +1,5 @@ +from .stlLexer import stlLexer +from .stlParser import stlParser +from .stl import STLAbstractSyntaxTreeExtractor +from .stl import Operation, RelOperation, STLFormula, Trace, TraceBatch +from .stl import to_ast diff --git a/stl/agm.py b/src/pytelo/stl/agm.py similarity index 98% rename from stl/agm.py rename to src/pytelo/stl/agm.py index 699d646..93670da 100644 --- a/stl/agm.py +++ b/src/pytelo/stl/agm.py @@ -9,8 +9,8 @@ import numpy as np from antlr4 import InputStream, CommonTokenStream -from stlLexer import stlLexer -from stlParser import stlParser +from .stlLexer import stlLexer +from .stlParser import stlParser from stl import Operation, RelOperation, STLAbstractSyntaxTreeExtractor, Trace diff --git a/stl/stl.g4 b/src/pytelo/stl/stl.g4 similarity index 100% rename from stl/stl.g4 rename to src/pytelo/stl/stl.g4 diff --git a/stl/stl.py b/src/pytelo/stl/stl.py similarity index 99% rename from stl/stl.py rename to src/pytelo/stl/stl.py index a9ea3ec..8df0ba7 100644 --- a/stl/stl.py +++ b/src/pytelo/stl/stl.py @@ -11,9 +11,9 @@ from scipy.interpolate import interp1d from antlr4 import InputStream, CommonTokenStream -from stlLexer import stlLexer -from stlParser import stlParser -from stlVisitor import stlVisitor +from .stlLexer import stlLexer +from .stlParser import stlParser +from .stlVisitor import stlVisitor class Operation(object): diff --git a/stl/stl2milp.py b/src/pytelo/stl/stl2milp.py similarity index 98% rename from stl/stl2milp.py rename to src/pytelo/stl/stl2milp.py index 0ae59d8..f0c0312 100644 --- a/stl/stl2milp.py +++ b/src/pytelo/stl/stl2milp.py @@ -7,7 +7,7 @@ import gurobipy as grb -from stl import Operation, RelOperation, STLFormula +from .stl import Operation, RelOperation, STLFormula class stl2milp(object): @@ -86,7 +86,6 @@ def add_state(self, state, t): name='{}_{}'.format(state, t) v = self.model.addVar(vtype=vtype, lb=low, ub=high, name=name) self.variables[state][t] = v - print 'Added state:', state, 'time:', t self.model.update() return self.variables[state][t] diff --git a/stl/test/stl2milp_test.py b/src/pytelo/stl/test/stl2milp_test.py similarity index 100% rename from stl/test/stl2milp_test.py rename to src/pytelo/stl/test/stl2milp_test.py diff --git a/stl/__init__.py b/stl/__init__.py deleted file mode 100644 index a75cfb5..0000000 --- a/stl/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from stlLexer import stlLexer -from stlParser import stlParser -from stl import STLAbstractSyntaxTreeExtractor -from stl import Operation, RelOperation, STLFormula, Trace \ No newline at end of file