Browse Source

Create project boilerplate

Arkadiusz Ryś 2 years ago
parent
commit
00a8fe8534
16 changed files with 353 additions and 92 deletions
  1. 10 0
      .dockerignore
  2. 18 0
      .editorconfig
  3. 7 0
      .gitignore
  4. 49 0
      .gitlab-ci.yml
  5. 13 0
      AUTHORS.rst
  6. 7 0
      HISTORY.rst
  7. 22 0
      LICENSE
  8. 0 92
      README.md
  9. 16 0
      README.rst
  10. 51 0
      docs/templates/pyproject.toml
  11. 3 0
      graph_exploring_tool/__init__.py
  12. 0 0
      graph_exploring_tool/__main__.py
  13. 0 0
      graph_exploring_tool/main.py
  14. 51 0
      pyproject.toml
  15. 25 0
      requirements.txt
  16. 81 0
      tasks.py

+ 10 - 0
.dockerignore

@@ -0,0 +1,10 @@
+__pycache__/
+*$py.class
+/.git
+/.idea
+/docs
+/data
+/.dockerignore
+/.gitignore
+/.gitlab-ci.yml
+/README.md

+ 18 - 0
.editorconfig

@@ -0,0 +1,18 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{css, html, yml, yaml, js, xml}]
+indent_size = 2
+
+[{*.log, LICENSE}]
+insert_final_newline = false
+
+[*.rst]
+indent_size = 3

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+__pycache__/
+venv/
+build/
+dist/
+*.egg-info
+
+*.log

+ 49 - 0
.gitlab-ci.yml

@@ -0,0 +1,49 @@
+image: docker:20.10.22
+
+variables:
+  DOCKER_DRIVER: overlay2
+  DOCKER_TLS_CERTDIR: "/certs"
+  DOCKER_HOST: tcp://docker:2376
+  # Where to publish this build's tagged working container.
+  DOCKER_SHA: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
+  DOCKER_BRANCH: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+  DOCKER_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
+  DOCKER_LATEST: $CI_REGISTRY_IMAGE:latest
+
+services:
+  - docker:20.10.22-dind
+
+stages:
+  - build
+  - test
+  - release
+
+before_script:
+  - docker info
+  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+
+build-upload:
+  image: python:3.11
+  stage: build
+  before_script:
+    - python -V
+    - echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi"
+  script:
+    - pip install build twine flit
+    - FLIT_INDEX_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi flit build
+    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
+  only:
+    - tags
+
+.build-upload-pypi:
+  image: python:3.11
+  stage: build
+  before_script:
+    - python -V
+    - echo "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi"
+  script:
+    - pip install build twine flit
+    - flit build
+    - python -m twine upload dist/*
+  only:
+    - tags

+ 13 - 0
AUTHORS.rst

@@ -0,0 +1,13 @@
+=======
+Credits
+=======
+
+Development Lead
+----------------
+
+* Arkadiusz Michał Ryś <Arkadiusz.Michal.Rys@gmail.com>
+
+Contributors
+------------
+
+None yet. Why not be the first?

+ 7 - 0
HISTORY.rst

@@ -0,0 +1,7 @@
+=======
+History
+=======
+
+0.0.0 (yyyy-mm-dd)
+------------------
+* No history yet.

+ 22 - 0
LICENSE

@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2023, Arkadiusz Michał Ryś
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+

File diff suppressed because it is too large
+ 0 - 92
README.md


+ 16 - 0
README.rst

@@ -0,0 +1,16 @@
+####################
+Graph Exploring Tool
+####################
+
+Installation
+------------
+
+.. code-block:: shell
+
+   pip install graph-exploring-tool
+
+or
+
+.. code-block:: shell
+
+   pip install --index-url https://pip:glpat-m8mNfhxZAUnWvy7rLS1x@git.rys.one/api/v4/projects/264/packages/pypi/simple --no-deps graph-exploring-tool

+ 51 - 0
docs/templates/pyproject.toml

@@ -0,0 +1,51 @@
+[build-system]
+requires = ["flit_core >=3.2,<4"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "graph-exploring-tool"
+authors = [
+    {name = "Arkadiusz Michał Ryś", email = "Arkadiusz.Michal.Rys@gmail.com"},
+]
+readme = "README.rst"
+requires-python = ">=3.9"
+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 = ["graph"]
+dependencies = [
+{%- for dependency in requirements.graph_exploring_tool %}
+    "{{ 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 %}
+]
+graphical = [
+{%- for dependency in requirements.graphical %}
+    "{{ dependency }}",
+{%- endfor %}
+]
+
+[project.urls]
+source = "https://git.rys.one/dtdesign/graph-exploring-tool"

+ 3 - 0
graph_exploring_tool/__init__.py

@@ -0,0 +1,3 @@
+"""Graph Exploring Tool."""
+__version__ = "0.0.0"
+__version_info__ = tuple((int(num) if num.isdigit() else num for num in __version__.replace("-", ".", 1).split(".")))

+ 0 - 0
graph_exploring_tool/__main__.py


+ 0 - 0
graph_exploring_tool/main.py


+ 51 - 0
pyproject.toml

@@ -0,0 +1,51 @@
+[build-system]
+requires = ["flit_core >=3.2,<4"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "graph-exploring-tool"
+authors = [
+    {name = "Arkadiusz Michał Ryś", email = "Arkadiusz.Michal.Rys@gmail.com"},
+]
+readme = "README.rst"
+requires-python = ">=3.9"
+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 = ["graph"]
+dependencies = [
+    "arklog~=0.5.1",
+    "rdflib~=6.2.0",
+    "sparqlwrapper~=2.0.0",
+]
+
+[project.optional-dependencies]
+test = [
+    "pytest~=7.2.2",
+]
+doc = [
+    "sphinx~=6.1.3",
+]
+dev = [
+    "tox~=4.4.6",
+    "pip~=23.0.1",
+    "flit~=3.8.0",
+    "twine~=4.0.2",
+    "invoke~=2.0.0",
+    "jinja2~=3.1.2",
+    "flake8~=6.0.0",
+    "coverage~=7.2.1",
+]
+graphical = [
+    "glfw~=2.5.6",
+    "imgui[glfw]~=1.4.1",
+]
+
+[project.urls]
+source = "https://git.rys.one/dtdesign/graph-exploring-tool"

+ 25 - 0
requirements.txt

@@ -0,0 +1,25 @@
+# Graph Exploring Tool
+arklog        ~= 0.5.1
+rdflib        ~= 6.2.0
+sparqlwrapper ~= 2.0.0
+# Test
+pytest        ~= 7.2.2
+# Doc
+sphinx ~= 6.1.3
+# Dev
+tox      ~= 4.4.6
+pip      ~= 23.0.1
+flit     ~= 3.8.0
+twine    ~= 4.0.2
+invoke   ~= 2.0.0
+jinja2   ~= 3.1.2
+flake8   ~= 6.0.0
+coverage ~= 7.2.1
+# pylode   ~= 3.0.4
+# owlready2     ~= 0.40
+# graphviz      ~= 0.20.1
+# pyshacl[js]   ~= 0.20.0
+# pydot         ~= 1.4.2
+# Graphical
+glfw        ~= 2.5.6
+imgui[glfw] ~= 1.4.1

+ 81 - 0
tasks.py

@@ -0,0 +1,81 @@
+from pathlib import Path
+
+from invoke import task
+from jinja2 import Template
+
+
+@task
+def lint(c):
+    """"""
+    system = "graph_exploring_tool"
+    c.run(f"python3 -m black {system}")
+    c.run(f"python3 -m pylint {system}")
+
+
+@task(name="docs")
+def documentation(c):
+    """Build the documentation."""
+    c.run("python3 -m sphinx docs docs/build/html")
+
+
+@task
+def test(c):
+    """Run all tests under the tests directory."""
+    c.run("python3 -m unittest discover tests 'test_*' -v")
+
+
+@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"
+    requirements = {current: [], "test": [], "doc": [], "graphical": [], "dev": []}
+    for line in lines:
+        if line.startswith("#"):
+            candidate = line[1:].lower().strip().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))
+
+
+@task
+def release(c, version):
+    """"""
+    if version not in ["minor", "major", "patch"]:
+        print("Version can be either major, minor or patch.")
+        return
+
+    from graph_exploring_tool import __version_info__, __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")
+    c.run(f"sed -i 's/{__version__}/{_major}.{_minor}.{_patch}/g' graph_exploring_tool/__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")
+    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")
+    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")