From 238ac63c2a65b396d38a31969efadb882f377e01 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 08:13:43 +0300 Subject: [PATCH 1/6] Change to use src structure --- .gitmodules | 4 ++-- README.md | 6 +++--- arho-feature-template.code-workspace | 2 +- pyproject.toml | 1 + .../arho_feature_template}/.gitattributes | 0 .../arho_feature_template}/__init__.py | 0 .../arho_feature_template}/build.py | 0 .../arho_feature_template}/core/__init__.py | 0 .../arho_feature_template}/core/feature_template.py | 0 .../arho_feature_template}/core/feature_template_library.py | 0 .../arho_feature_template}/core/forms/__init__.py | 0 .../arho_feature_template}/core/forms/add_feature_form.py | 0 .../core/forms/feature_attribute_form.py | 0 .../core/forms/feature_attribute_form.ui | 0 .../arho_feature_template}/core/panels/__init__.py | 0 .../core/panels/template_library_panel.py | 0 .../core/panels/template_library_panel.ui | 0 .../arho_feature_template}/metadata.txt | 0 .../arho_feature_template}/plugin.py | 0 .../arho_feature_template}/qgis_plugin_tools | 0 .../arho_feature_template}/resources/.gitignore | 0 .../resources/asemakaava-template-library-test.json | 0 .../arho_feature_template}/resources/i18n/.gitignore | 0 .../arho_feature_template}/resources/icons/.gitignore | 0 .../arho_feature_template}/resources/ui/.gitignore | 0 25 files changed, 7 insertions(+), 6 deletions(-) rename {arho_feature_template => src/arho_feature_template}/.gitattributes (100%) rename {arho_feature_template => src/arho_feature_template}/__init__.py (100%) rename {arho_feature_template => src/arho_feature_template}/build.py (100%) mode change 100755 => 100644 rename {arho_feature_template => src/arho_feature_template}/core/__init__.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/feature_template.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/feature_template_library.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/forms/__init__.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/forms/add_feature_form.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/forms/feature_attribute_form.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/forms/feature_attribute_form.ui (100%) rename {arho_feature_template => src/arho_feature_template}/core/panels/__init__.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/panels/template_library_panel.py (100%) rename {arho_feature_template => src/arho_feature_template}/core/panels/template_library_panel.ui (100%) rename {arho_feature_template => src/arho_feature_template}/metadata.txt (100%) rename {arho_feature_template => src/arho_feature_template}/plugin.py (100%) rename {arho_feature_template => src/arho_feature_template}/qgis_plugin_tools (100%) rename {arho_feature_template => src/arho_feature_template}/resources/.gitignore (100%) rename {arho_feature_template => src/arho_feature_template}/resources/asemakaava-template-library-test.json (100%) rename {arho_feature_template => src/arho_feature_template}/resources/i18n/.gitignore (100%) rename {arho_feature_template => src/arho_feature_template}/resources/icons/.gitignore (100%) rename {arho_feature_template => src/arho_feature_template}/resources/ui/.gitignore (100%) diff --git a/.gitmodules b/.gitmodules index 02a707e..b0df7bc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "arho_feature_template/qgis_plugin_tools"] - path = arho_feature_template/qgis_plugin_tools +[submodule "src/arho_feature_template/qgis_plugin_tools"] + path = src/arho_feature_template/qgis_plugin_tools url = https://github.com/GispoCoding/qgis_plugin_tools diff --git a/README.md b/README.md index 3b640e7..dcd8dfb 100644 --- a/README.md +++ b/README.md @@ -24,17 +24,17 @@ A symbolic link / directory junction should be made to the directory containing On Windows Command promt ```console -mklink /J %AppData%\QGIS\QGIS3\profiles\default\python\plugins\arho_feature_template .\arho_feature_template +mklink /J %AppData%\QGIS\QGIS3\profiles\default\python\plugins\arho_feature_template .\src\arho_feature_template ``` On Windows PowerShell ```console -New-Item -ItemType SymbolicLink -Path ${env:APPDATA}\QGIS\QGIS3\profiles\default\python\plugins\arho_feature_template -Value ${pwd}\arho_feature_template +New-Item -ItemType SymbolicLink -Path ${env:APPDATA}\QGIS\QGIS3\profiles\default\python\plugins\arho_feature_template -Value ${pwd}\src\arho_feature_template ``` On Linux ```console -ln -s arho_feature_template/ ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/arho_feature_template +ln -s src/arho_feature_template/ ~/.local/share/QGIS/QGIS3/profiles/default/python/plugins/arho_feature_template ``` After that you should be able to enable the plugin in the QGIS Plugin Manager. diff --git a/arho-feature-template.code-workspace b/arho-feature-template.code-workspace index 6d62132..d346401 100644 --- a/arho-feature-template.code-workspace +++ b/arho-feature-template.code-workspace @@ -40,7 +40,7 @@ }, "pathMappings": [ { - "localRoot": "${workspaceFolder}/arho_feature_template", + "localRoot": "${workspaceFolder}/src/arho_feature_template", "remoteRoot": "${env:APPDATA}/QGIS/QGIS3/profiles/default/python/plugins/arho_feature_template" } ] diff --git a/pyproject.toml b/pyproject.toml index d8ae2c9..b678802 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ version = "0.1.0" requires-python = ">= 3.8" [tool.setuptools] +package-dir = {"" = "src"} packages = ["arho_feature_template"] [tool.pytest.ini_options] diff --git a/arho_feature_template/.gitattributes b/src/arho_feature_template/.gitattributes similarity index 100% rename from arho_feature_template/.gitattributes rename to src/arho_feature_template/.gitattributes diff --git a/arho_feature_template/__init__.py b/src/arho_feature_template/__init__.py similarity index 100% rename from arho_feature_template/__init__.py rename to src/arho_feature_template/__init__.py diff --git a/arho_feature_template/build.py b/src/arho_feature_template/build.py old mode 100755 new mode 100644 similarity index 100% rename from arho_feature_template/build.py rename to src/arho_feature_template/build.py diff --git a/arho_feature_template/core/__init__.py b/src/arho_feature_template/core/__init__.py similarity index 100% rename from arho_feature_template/core/__init__.py rename to src/arho_feature_template/core/__init__.py diff --git a/arho_feature_template/core/feature_template.py b/src/arho_feature_template/core/feature_template.py similarity index 100% rename from arho_feature_template/core/feature_template.py rename to src/arho_feature_template/core/feature_template.py diff --git a/arho_feature_template/core/feature_template_library.py b/src/arho_feature_template/core/feature_template_library.py similarity index 100% rename from arho_feature_template/core/feature_template_library.py rename to src/arho_feature_template/core/feature_template_library.py diff --git a/arho_feature_template/core/forms/__init__.py b/src/arho_feature_template/core/forms/__init__.py similarity index 100% rename from arho_feature_template/core/forms/__init__.py rename to src/arho_feature_template/core/forms/__init__.py diff --git a/arho_feature_template/core/forms/add_feature_form.py b/src/arho_feature_template/core/forms/add_feature_form.py similarity index 100% rename from arho_feature_template/core/forms/add_feature_form.py rename to src/arho_feature_template/core/forms/add_feature_form.py diff --git a/arho_feature_template/core/forms/feature_attribute_form.py b/src/arho_feature_template/core/forms/feature_attribute_form.py similarity index 100% rename from arho_feature_template/core/forms/feature_attribute_form.py rename to src/arho_feature_template/core/forms/feature_attribute_form.py diff --git a/arho_feature_template/core/forms/feature_attribute_form.ui b/src/arho_feature_template/core/forms/feature_attribute_form.ui similarity index 100% rename from arho_feature_template/core/forms/feature_attribute_form.ui rename to src/arho_feature_template/core/forms/feature_attribute_form.ui diff --git a/arho_feature_template/core/panels/__init__.py b/src/arho_feature_template/core/panels/__init__.py similarity index 100% rename from arho_feature_template/core/panels/__init__.py rename to src/arho_feature_template/core/panels/__init__.py diff --git a/arho_feature_template/core/panels/template_library_panel.py b/src/arho_feature_template/core/panels/template_library_panel.py similarity index 100% rename from arho_feature_template/core/panels/template_library_panel.py rename to src/arho_feature_template/core/panels/template_library_panel.py diff --git a/arho_feature_template/core/panels/template_library_panel.ui b/src/arho_feature_template/core/panels/template_library_panel.ui similarity index 100% rename from arho_feature_template/core/panels/template_library_panel.ui rename to src/arho_feature_template/core/panels/template_library_panel.ui diff --git a/arho_feature_template/metadata.txt b/src/arho_feature_template/metadata.txt similarity index 100% rename from arho_feature_template/metadata.txt rename to src/arho_feature_template/metadata.txt diff --git a/arho_feature_template/plugin.py b/src/arho_feature_template/plugin.py similarity index 100% rename from arho_feature_template/plugin.py rename to src/arho_feature_template/plugin.py diff --git a/arho_feature_template/qgis_plugin_tools b/src/arho_feature_template/qgis_plugin_tools similarity index 100% rename from arho_feature_template/qgis_plugin_tools rename to src/arho_feature_template/qgis_plugin_tools diff --git a/arho_feature_template/resources/.gitignore b/src/arho_feature_template/resources/.gitignore similarity index 100% rename from arho_feature_template/resources/.gitignore rename to src/arho_feature_template/resources/.gitignore diff --git a/arho_feature_template/resources/asemakaava-template-library-test.json b/src/arho_feature_template/resources/asemakaava-template-library-test.json similarity index 100% rename from arho_feature_template/resources/asemakaava-template-library-test.json rename to src/arho_feature_template/resources/asemakaava-template-library-test.json diff --git a/arho_feature_template/resources/i18n/.gitignore b/src/arho_feature_template/resources/i18n/.gitignore similarity index 100% rename from arho_feature_template/resources/i18n/.gitignore rename to src/arho_feature_template/resources/i18n/.gitignore diff --git a/arho_feature_template/resources/icons/.gitignore b/src/arho_feature_template/resources/icons/.gitignore similarity index 100% rename from arho_feature_template/resources/icons/.gitignore rename to src/arho_feature_template/resources/icons/.gitignore diff --git a/arho_feature_template/resources/ui/.gitignore b/src/arho_feature_template/resources/ui/.gitignore similarity index 100% rename from arho_feature_template/resources/ui/.gitignore rename to src/arho_feature_template/resources/ui/.gitignore From 9986d90a0cae6ef5714360ad347f3130cd4c66a9 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 08:32:29 +0300 Subject: [PATCH 2/6] Move gui components to own subpackage --- src/arho_feature_template/{core/forms => gui}/__init__.py | 0 .../{core/panels => gui/forms}/__init__.py | 0 .../{core => gui}/forms/add_feature_form.py | 2 +- .../{core => gui}/forms/feature_attribute_form.py | 0 .../{core => gui}/forms/feature_attribute_form.ui | 0 .../{resources/ui/.gitignore => gui/panels/__init__.py} | 0 .../{core => gui}/panels/template_library_panel.py | 0 .../{core => gui}/panels/template_library_panel.ui | 0 src/arho_feature_template/plugin.py | 2 +- 9 files changed, 2 insertions(+), 2 deletions(-) rename src/arho_feature_template/{core/forms => gui}/__init__.py (100%) rename src/arho_feature_template/{core/panels => gui/forms}/__init__.py (100%) rename src/arho_feature_template/{core => gui}/forms/add_feature_form.py (86%) rename src/arho_feature_template/{core => gui}/forms/feature_attribute_form.py (100%) rename src/arho_feature_template/{core => gui}/forms/feature_attribute_form.ui (100%) rename src/arho_feature_template/{resources/ui/.gitignore => gui/panels/__init__.py} (100%) rename src/arho_feature_template/{core => gui}/panels/template_library_panel.py (100%) rename src/arho_feature_template/{core => gui}/panels/template_library_panel.ui (100%) diff --git a/src/arho_feature_template/core/forms/__init__.py b/src/arho_feature_template/gui/__init__.py similarity index 100% rename from src/arho_feature_template/core/forms/__init__.py rename to src/arho_feature_template/gui/__init__.py diff --git a/src/arho_feature_template/core/panels/__init__.py b/src/arho_feature_template/gui/forms/__init__.py similarity index 100% rename from src/arho_feature_template/core/panels/__init__.py rename to src/arho_feature_template/gui/forms/__init__.py diff --git a/src/arho_feature_template/core/forms/add_feature_form.py b/src/arho_feature_template/gui/forms/add_feature_form.py similarity index 86% rename from src/arho_feature_template/core/forms/add_feature_form.py rename to src/arho_feature_template/gui/forms/add_feature_form.py index 45c40d6..574ee61 100644 --- a/src/arho_feature_template/core/forms/add_feature_form.py +++ b/src/arho_feature_template/gui/forms/add_feature_form.py @@ -1,5 +1,5 @@ from arho_feature_template.core.feature_template import FeatureTemplate -from arho_feature_template.core.forms.feature_attribute_form import FeatureAttributeForm +from arho_feature_template.gui.forms.feature_attribute_form import FeatureAttributeForm class AddFeatureForm(FeatureAttributeForm): diff --git a/src/arho_feature_template/core/forms/feature_attribute_form.py b/src/arho_feature_template/gui/forms/feature_attribute_form.py similarity index 100% rename from src/arho_feature_template/core/forms/feature_attribute_form.py rename to src/arho_feature_template/gui/forms/feature_attribute_form.py diff --git a/src/arho_feature_template/core/forms/feature_attribute_form.ui b/src/arho_feature_template/gui/forms/feature_attribute_form.ui similarity index 100% rename from src/arho_feature_template/core/forms/feature_attribute_form.ui rename to src/arho_feature_template/gui/forms/feature_attribute_form.ui diff --git a/src/arho_feature_template/resources/ui/.gitignore b/src/arho_feature_template/gui/panels/__init__.py similarity index 100% rename from src/arho_feature_template/resources/ui/.gitignore rename to src/arho_feature_template/gui/panels/__init__.py diff --git a/src/arho_feature_template/core/panels/template_library_panel.py b/src/arho_feature_template/gui/panels/template_library_panel.py similarity index 100% rename from src/arho_feature_template/core/panels/template_library_panel.py rename to src/arho_feature_template/gui/panels/template_library_panel.py diff --git a/src/arho_feature_template/core/panels/template_library_panel.ui b/src/arho_feature_template/gui/panels/template_library_panel.ui similarity index 100% rename from src/arho_feature_template/core/panels/template_library_panel.ui rename to src/arho_feature_template/gui/panels/template_library_panel.ui diff --git a/src/arho_feature_template/plugin.py b/src/arho_feature_template/plugin.py index 9b7b3a6..3bb0804 100644 --- a/src/arho_feature_template/plugin.py +++ b/src/arho_feature_template/plugin.py @@ -9,7 +9,7 @@ from qgis.utils import iface from arho_feature_template.core.feature_template_library import FeatureTemplateLibrary -from arho_feature_template.core.panels.template_library_panel import TemplateLibraryPanel +from arho_feature_template.gui.panels.template_library_panel import TemplateLibraryPanel from arho_feature_template.qgis_plugin_tools.tools.custom_logging import setup_logger, teardown_logger from arho_feature_template.qgis_plugin_tools.tools.i18n import setup_translation from arho_feature_template.qgis_plugin_tools.tools.resources import plugin_name, resources_path From 27f8d693bac0360e132b53dfdf97e43227abb90b Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 08:35:39 +0300 Subject: [PATCH 3/6] Delete build script We don't need to compile any source files anymore so there is no need to build the plugin. Use a symlink to test the plugin instead. --- src/arho_feature_template/build.py | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 src/arho_feature_template/build.py diff --git a/src/arho_feature_template/build.py b/src/arho_feature_template/build.py deleted file mode 100644 index 2e6cd3d..0000000 --- a/src/arho_feature_template/build.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python -from __future__ import annotations - -import glob - -from qgis_plugin_tools.infrastructure.plugin_maker import PluginMaker - -""" -################################################# -# Edit the following to match the plugin -################################################# -""" - -py_files = [fil for fil in glob.glob("**/*.py", recursive=True) if "test/" not in fil and "test\\" not in fil] -locales = ["fi"] -profile = "arho" -ui_files = list(glob.glob("**/*.ui", recursive=True)) -resources = list(glob.glob("**/*.qrc", recursive=True)) -extra_dirs = ["resources"] -compiled_resources: list[str] = [] - -PluginMaker( - py_files=py_files, - ui_files=ui_files, - resources=resources, - extra_dirs=extra_dirs, - compiled_resources=compiled_resources, - locales=locales, - profile=profile, -) From 226c006c9dfb6555748b68287ffcb1fe4f1110e9 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 09:56:47 +0300 Subject: [PATCH 4/6] Use default gitignore template Use default gitignore template from GitHub to reduce the risk to commit undesired files. --- .gitignore | 167 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 161 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 87041a6..82f9275 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,162 @@ -arho-feature-template/i18n +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ venv/ -.venv/ -start_ide.bat -.vscode -*/.pytest_cache -__pycache__ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ From b0c98ded1486423b6460b31b57b59d5fe1a6f1a9 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 09:58:03 +0300 Subject: [PATCH 5/6] Move qgis-plugin-ci config to pyproject --- .qgis-plugin-ci | 5 ----- pyproject.toml | 8 +++++--- 2 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 .qgis-plugin-ci diff --git a/.qgis-plugin-ci b/.qgis-plugin-ci deleted file mode 100644 index 33a47bf..0000000 --- a/.qgis-plugin-ci +++ /dev/null @@ -1,5 +0,0 @@ -plugin_path: arho_feature_template -github_organization_slug: GispoCoding -project_slug: arho-feature-template -transifex_coordinator: replace-me -transifex_organization: replace-me diff --git a/pyproject.toml b/pyproject.toml index b678802..4e2b92c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,12 +21,9 @@ omit = ["arho_feature_template/qgis_plugin_tools/*"] [tool.ruff] target-version = "py38" extend = "ruff_defaults.toml" - - exclude = ["arho_feature_template/qgis_plugin_tools"] [tool.ruff.lint] - unfixable = [ "F401", # unused imports "F841", # unused variables @@ -39,3 +36,8 @@ ignore_errors = true [[tool.mypy.overrides]] module = ["qgis.*", "osgeo.*"] ignore_missing_imports = true + +[tool.qgis-plugin-ci] +plugin_path = "src/arho_feature_template" +github_organization_slug= "GispoCoding" +project_slug = "arho-feature-template" From d10d4564b940feec375b0052d375a9a2aa4938c2 Mon Sep 17 00:00:00 2001 From: Lauri Kajan Date: Fri, 27 Sep 2024 09:58:36 +0300 Subject: [PATCH 6/6] Add instruction to install test dependencies also --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dcd8dfb..ce88558 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Create a virtual environment activate it and install needed dependencies with th ```console python create_qgis_venv.py .venv\Scripts\activate # On Linux and macOS run `source .venv\bin\activate` -pip install -r requirements-dev.txt +pip install -r requirements-dev.txt -r requirements-test.txt ``` For more detailed development instructions see [development](docs/development.md).