|
@@ -3,11 +3,11 @@ from pathlib import Path
|
|
|
from invoke import task
|
|
|
from jinja2 import Template
|
|
|
|
|
|
+system = "graph_exploring_tool" # Directory name of the project
|
|
|
|
|
|
@task
|
|
|
def lint(c):
|
|
|
""""""
|
|
|
- system = "graph_exploring_tool"
|
|
|
c.run(f"python3 -m black {system}")
|
|
|
c.run(f"python3 -m pylint {system}")
|
|
|
|
|
@@ -18,21 +18,50 @@ def documentation(c):
|
|
|
c.run("python3 -m sphinx docs docs/build/html")
|
|
|
|
|
|
|
|
|
+@task(name="preview", aliases=("rst",))
|
|
|
+def preview(c):
|
|
|
+ """Show a preview of the README file."""
|
|
|
+ rst_view = c.run(f"restview --listen=8888 --browser --pypi-strict README.rst", asynchronous=True, out_stream=sys.stdout)
|
|
|
+ print("Listening on http://localhost:8888/")
|
|
|
+ rst_view.join()
|
|
|
+
|
|
|
+
|
|
|
+@task
|
|
|
+def clean(c):
|
|
|
+ """Remove all artefacts."""
|
|
|
+ patterns = ["build", "docs/build"]
|
|
|
+ for pattern in patterns:
|
|
|
+ c.run(f"rm -rf {pattern}")
|
|
|
+
|
|
|
+
|
|
|
@task
|
|
|
def test(c):
|
|
|
"""Run all tests under the tests directory."""
|
|
|
c.run("python3 -m unittest discover tests 'test_*' -v")
|
|
|
|
|
|
|
|
|
+@task
|
|
|
+def coverage(c):
|
|
|
+ """Run coverage from the 'tests' directory."""
|
|
|
+ c.run("coverage run --source . -m unittest discover tests 'test_*' -v")
|
|
|
+ c.run("coverage html")
|
|
|
+
|
|
|
+
|
|
|
+@task
|
|
|
+def minimum(c):
|
|
|
+ """Check the minimum required python version for the project."""
|
|
|
+ c.run("vermin --no-parse-comments .")
|
|
|
+
|
|
|
+
|
|
|
@task(name="migrate")
|
|
|
def migrate_requirements(c):
|
|
|
"""Copy requirements from the requirements.txt file to pyproject.toml."""
|
|
|
lines = Path("requirements.txt").read_text().split("\n")
|
|
|
- current = "graph_exploring_tool"
|
|
|
+ current = system.lower().replace("-", "_")
|
|
|
requirements = {current: [], "test": [], "doc": [], "graphical": [], "dev": []}
|
|
|
for line in lines:
|
|
|
if line.startswith("#"):
|
|
|
- candidate = line[1:].lower().strip().replace(" ", "_")
|
|
|
+ candidate = line[1:].lower().strip().replace(" ", "_").replace("-", "_")
|
|
|
if candidate in requirements.keys():
|
|
|
current = candidate
|
|
|
continue
|
|
@@ -50,7 +79,10 @@ def release(c, version):
|
|
|
print("Version can be either major, minor or patch.")
|
|
|
return
|
|
|
|
|
|
- from graph_exploring_tool import __version_info__, __version__
|
|
|
+ import importlib
|
|
|
+ current_module = importlib.import_module(system)
|
|
|
+ __version_info__ = current_module.__version_info__
|
|
|
+ __version__ = current_module.__version__
|
|
|
_major, _minor, _patch = __version_info__
|
|
|
|
|
|
if version == "patch":
|
|
@@ -64,7 +96,7 @@ def release(c, version):
|
|
|
_patch = 0
|
|
|
|
|
|
c.run(f"git checkout -b release-{_major}.{_minor}.{_patch} dev")
|
|
|
- c.run(f"sed -i 's/{__version__}/{_major}.{_minor}.{_patch}/g' graph_exploring_tool/__init__.py")
|
|
|
+ c.run(f"sed -i 's/{__version__}/{_major}.{_minor}.{_patch}/g' {system}/__init__.py")
|
|
|
print(f"Update the readme for version {_major}.{_minor}.{_patch}.")
|
|
|
input("Press enter when ready.")
|
|
|
c.run(f"git add -u")
|