|
|
@@ -1,5 +1,5 @@
|
|
|
from pathlib import Path
|
|
|
-
|
|
|
+import rys
|
|
|
from invoke import task
|
|
|
from jinja2 import Template
|
|
|
|
|
|
@@ -7,7 +7,60 @@ 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_tamplate = """
|
|
|
+[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"
|
|
|
+
|
|
|
+[tool.flit.sdist]
|
|
|
+exclude = [".gitignore", ".git", ".idea", "tasks.py", ".editorconfig", ".gitlab-ci.yml", "requirements.txt"]
|
|
|
+
|
|
|
+"""
|
|
|
@task
|
|
|
def lint(c):
|
|
|
""""""
|
|
|
@@ -62,58 +115,10 @@ def minimum(c):
|
|
|
@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 = system.lower().replace("-", "_")
|
|
|
- requirements = {current: [], "test": [], "doc": [], "graphical": [], "dev": []}
|
|
|
- for line in lines:
|
|
|
- if line.startswith("#"):
|
|
|
- candidate = line[1:].lower().strip().replace(" ", "_").replace("-", "_")
|
|
|
- if candidate in requirements.keys():
|
|
|
- current = candidate
|
|
|
- continue
|
|
|
- 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))
|
|
|
+ rys.migrate_requirements(c, project_template, system)
|
|
|
|
|
|
|
|
|
@task
|
|
|
def release(c, version):
|
|
|
""""""
|
|
|
- if version not in ["minor", "major", "patch"]:
|
|
|
- print("Version can be either major, minor or patch.")
|
|
|
- return
|
|
|
-
|
|
|
- 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":
|
|
|
- _patch = _patch + 1
|
|
|
- elif version == "minor":
|
|
|
- _minor = _minor + 1
|
|
|
- _patch = 0
|
|
|
- elif version == "major":
|
|
|
- _major = _major + 1
|
|
|
- _minor = 0
|
|
|
- _patch = 0
|
|
|
-
|
|
|
- c.run(f"git checkout -b release-{_major}.{_minor}.{_patch} {dev_branch}")
|
|
|
- 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")
|
|
|
- c.run(f'git commit -m "Update changelog version {_major}.{_minor}.{_patch}"')
|
|
|
- c.run(f"git push --set-upstream origin release-{_major}.{_minor}.{_patch}")
|
|
|
- c.run(f"git checkout {main_branch}")
|
|
|
- c.run(f"git merge --no-ff release-{_major}.{_minor}.{_patch}")
|
|
|
- c.run(f'git tag -a {_major}.{_minor}.{_patch} -m "Release {_major}.{_minor}.{_patch}"')
|
|
|
- c.run(f"git push")
|
|
|
- c.run(f"git checkout {dev_branch}")
|
|
|
- c.run(f"git merge --no-ff release-{_major}.{_minor}.{_patch}")
|
|
|
- c.run(f"git push")
|
|
|
- c.run(f"git branch -d release-{_major}.{_minor}.{_patch}")
|
|
|
- c.run(f"git push origin --tags")
|
|
|
+ rys.release(c, version, project_template, system, main_branch, dev_branch)
|