|
@@ -3,9 +3,63 @@ from pathlib import Path
|
|
|
from invoke import task
|
|
|
from jinja2 import Template
|
|
|
|
|
|
-system = "mocka" # Directory name of the project
|
|
|
-main_branch = "main" # The release branch on origin
|
|
|
-dev_branch = "dev" # The main development branch on origin
|
|
|
+system = "mocka" # Directory name of the project
|
|
|
+main_branch = "main" # The release branch on origin
|
|
|
+dev_branch = "dev" # The main development branch on origin
|
|
|
+
|
|
|
+project_template = """
|
|
|
+[build-system]
|
|
|
+requires = ["flit_core >=3.9,<4"]
|
|
|
+build-backend = "flit_core.buildapi"
|
|
|
+
|
|
|
+[project]
|
|
|
+name = "{{ system }}"
|
|
|
+authors = [
|
|
|
+ {name = "Arkadiusz Michał Ryś", email = "Arkadiusz.Michal.Rys@gmail.com"},
|
|
|
+ {name = "Lucas Albertins de Lima", email = "lucas.albertinsdelima@uantwerpen.be"},
|
|
|
+ {name = "Rakshit Mittal", email = "rakshit.mittal@uantwerpen.be"},
|
|
|
+]
|
|
|
+readme = "README.md"
|
|
|
+requires-python = ">={{ minimum_version }}"
|
|
|
+classifiers = [
|
|
|
+ "License :: OSI Approved :: MIT License",
|
|
|
+ "Programming Language :: Python :: 3",
|
|
|
+ "Development Status :: 2 - Pre-Alpha",
|
|
|
+ "Intended Audience :: Developers",
|
|
|
+ "Natural Language :: English",
|
|
|
+]
|
|
|
+dynamic = ["version", "description"]
|
|
|
+license = {file = "LICENSE"}
|
|
|
+keywords = ["mocka"]
|
|
|
+dependencies = [
|
|
|
+{%- for dependency in requirements.mocka %}
|
|
|
+ "{{ dependency }}",
|
|
|
+{%- endfor %}
|
|
|
+]
|
|
|
+
|
|
|
+[project.optional-dependencies]
|
|
|
+test = [
|
|
|
+{%- for dependency in requirements.test %}
|
|
|
+ "{{ dependency }}",
|
|
|
+{%- endfor %}
|
|
|
+]
|
|
|
+doc = [
|
|
|
+{%- for dependency in requirements.doc %}
|
|
|
+ "{{ dependency }}",
|
|
|
+{%- endfor %}
|
|
|
+]
|
|
|
+dev = [
|
|
|
+{%- for dependency in requirements.dev %}
|
|
|
+ "{{ dependency }}",
|
|
|
+{%- endfor %}
|
|
|
+]
|
|
|
+
|
|
|
+[project.urls]
|
|
|
+source = "https://git.rys.one/dtdesign/mocka"
|
|
|
+
|
|
|
+[project.scripts]
|
|
|
+mocka = "mocka.cli:entry_point"
|
|
|
+"""
|
|
|
|
|
|
|
|
|
@task
|
|
@@ -41,7 +95,7 @@ def clean(c):
|
|
|
@task
|
|
|
def test(c):
|
|
|
"""Run all tests under the tests directory."""
|
|
|
- c.run("python3 -m unittest discover tests 'test_*' -v")
|
|
|
+ c.run("python3 -m pytest")
|
|
|
|
|
|
|
|
|
@task
|
|
@@ -74,8 +128,14 @@ def migrate_requirements(c):
|
|
|
if line.strip() == "" or ("=" in line and "#" in line):
|
|
|
continue
|
|
|
requirements[current].append("".join(line.split()))
|
|
|
- template = Template(Path("docs/templates/pyproject.toml").read_text())
|
|
|
- Path("pyproject.toml").write_text(template.render(requirements=requirements))
|
|
|
+ import vermin
|
|
|
+ config = vermin.Config()
|
|
|
+ source_file_paths = list(set(vermin.detect_paths([system, "tests", "docs"], config=config)))
|
|
|
+ minimums, *_ = vermin.Processor().process(source_file_paths, config, config.processes())
|
|
|
+ minimum_version = vermin.version_strings(list(filter(lambda ver: ver, minimums)))
|
|
|
+ Path("pyproject.toml").write_text(
|
|
|
+ Template(project_template[1:]).render(requirements=requirements, system=system, minimum_version=minimum_version)
|
|
|
+ )
|
|
|
|
|
|
|
|
|
@task
|
|
@@ -85,6 +145,8 @@ def release(c, version):
|
|
|
print("Version can be either major, minor or patch.")
|
|
|
return
|
|
|
|
|
|
+ migrate_requirements(c)
|
|
|
+
|
|
|
import importlib
|
|
|
current_module = importlib.import_module(system)
|
|
|
__version_info__ = current_module.__version_info__
|