qgis-plugin-dev-tools 0.8.0__py3-none-any.whl → 0.9.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@
20
20
  import logging
21
21
  import sys
22
22
 
23
- __version__ = "0.8.0"
23
+ __version__ = "0.9.0"
24
24
 
25
25
  LOGGER = logging.getLogger(__name__)
26
26
  _handler = logging.StreamHandler(sys.stdout)
@@ -35,6 +35,7 @@ from qgis_plugin_dev_tools.build.metadata import update_metadata_file
35
35
  from qgis_plugin_dev_tools.build.packaging import (
36
36
  copy_plugin_code,
37
37
  copy_runtime_requirements,
38
+ copy_license,
38
39
  )
39
40
  from qgis_plugin_dev_tools.config import DevToolsConfig, VersionNumberSource
40
41
 
@@ -84,6 +85,7 @@ def make_plugin_zip(
84
85
  changelog_contents,
85
86
  )
86
87
  copy_runtime_requirements(dev_tools_config, build_directory_path)
88
+ copy_license(dev_tools_config, build_directory_path)
87
89
 
88
90
  LOGGER.debug("creating built plugin zip file from build directory")
89
91
 
@@ -20,6 +20,8 @@
20
20
  import logging
21
21
  import shutil
22
22
  import sys
23
+ from typing import Generator, Optional
24
+
23
25
  from importlib_metadata import Distribution
24
26
  from pathlib import Path
25
27
 
@@ -133,6 +135,45 @@ def copy_runtime_requirements(
133
135
  )
134
136
 
135
137
 
138
+ def copy_license(dev_tools_config: DevToolsConfig, build_directory_path: Path) -> None:
139
+ plugin_build_path = build_directory_path / dev_tools_config.plugin_package_name
140
+ target_license_file = plugin_build_path / "LICENSE"
141
+ license_file = dev_tools_config.license_file_path
142
+ if license_file is not None:
143
+ if not license_file.exists():
144
+ LOGGER.error(
145
+ f"Configured license file "
146
+ f"{license_file} "
147
+ f"does not exist. Check the configuration."
148
+ )
149
+ return
150
+
151
+ if target_license_file.exists():
152
+ LOGGER.warning(
153
+ f"Overwriting existing license {target_license_file} "
154
+ f"with configured license {license_file}"
155
+ )
156
+ LOGGER.debug(f"Copying license file {license_file} to {build_directory_path}")
157
+ shutil.copy(license_file, target_license_file)
158
+ return
159
+
160
+ if target_license_file.exists():
161
+ LOGGER.debug(f"Existing license file {target_license_file} found.")
162
+ return
163
+
164
+ # Try finding the license
165
+ license_file = _find_existing_license_file(dev_tools_config.pyproject_path)
166
+ if not license_file:
167
+ LOGGER.warning(
168
+ "Cannot copy LICENSE file since it does not exist. "
169
+ "Configure valid LICENSE file with license_file_path in pyproject.toml"
170
+ )
171
+ return
172
+
173
+ LOGGER.debug(f"Copying license file {license_file} to {build_directory_path}")
174
+ shutil.copy(license_file, target_license_file)
175
+
176
+
136
177
  def _copy_distribution_files(
137
178
  distribution: Distribution,
138
179
  top_level_names: set[str],
@@ -190,3 +231,15 @@ def _copy_distribution_files(
190
231
  src=original_path,
191
232
  dst=new_path,
192
233
  )
234
+
235
+
236
+ def _find_existing_license_file(search_path: Path) -> Optional[Path]:
237
+ def generate_license_candidates() -> Generator[Path, None, None]:
238
+ for base_name in ("LICENSE", "license"):
239
+ for extension in ("", ".md", ".MD"):
240
+ yield search_path / f"{base_name}{extension}"
241
+
242
+ for potential_path in generate_license_candidates():
243
+ if potential_path.exists():
244
+ return potential_path
245
+ return None
@@ -21,6 +21,7 @@ from collections import ChainMap
21
21
  from enum import Enum, auto
22
22
  from importlib.util import find_spec
23
23
  from pathlib import Path
24
+ from typing import Optional
24
25
 
25
26
  from importlib_metadata import Distribution, distribution
26
27
  from packaging.requirements import Requirement
@@ -42,6 +43,7 @@ class VersionNumberSource(Enum):
42
43
 
43
44
 
44
45
  class DevToolsConfig:
46
+ pyproject_path: Path
45
47
  plugin_package_name: str
46
48
  plugin_package_path: Path
47
49
  runtime_distributions: list[Distribution]
@@ -49,9 +51,11 @@ class DevToolsConfig:
49
51
  append_distributions_to_path: bool
50
52
  version_number_source: VersionNumberSource
51
53
  disabled_extra_plugins: list[str]
54
+ license_file_path: Optional[Path]
52
55
 
53
56
  def __init__( # noqa: PLR0913
54
57
  self,
58
+ pyproject_path: Path,
55
59
  plugin_package_name: str,
56
60
  runtime_requires: list[str],
57
61
  changelog_file_path: Path,
@@ -59,6 +63,7 @@ class DevToolsConfig:
59
63
  auto_add_recursive_runtime_dependencies: bool,
60
64
  version_number_source: VersionNumberSource,
61
65
  disabled_extra_plugins: list[str],
66
+ license_file_path: Optional[Path],
62
67
  ) -> None:
63
68
  plugin_package_spec = find_spec(plugin_package_name)
64
69
  if plugin_package_spec is None or plugin_package_spec.origin is None:
@@ -66,6 +71,7 @@ class DevToolsConfig:
66
71
  f"could not find {plugin_package_name=} in the current environment"
67
72
  )
68
73
 
74
+ self.pyproject_path = pyproject_path
69
75
  self.plugin_package_path = Path(plugin_package_spec.origin).parent
70
76
  self.plugin_package_name = plugin_package_name
71
77
  # TODO: check versions are satisfied?
@@ -77,6 +83,7 @@ class DevToolsConfig:
77
83
  self.version_number_source = version_number_source
78
84
  self.extra_runtime_distributions = []
79
85
  self.disabled_extra_plugins = disabled_extra_plugins
86
+ self.license_file_path = license_file_path
80
87
 
81
88
  if auto_add_recursive_runtime_dependencies:
82
89
  # Add the requirements of the distributions as well
@@ -98,6 +105,7 @@ class DevToolsConfig:
98
105
  def from_pyproject_config(pyproject_file_path: Path) -> "DevToolsConfig":
99
106
  pyproject_config = read_pyproject_config(pyproject_file_path)
100
107
  return DevToolsConfig(
108
+ pyproject_path=pyproject_file_path,
101
109
  plugin_package_name=pyproject_config.plugin_package_name,
102
110
  runtime_requires=pyproject_config.runtime_requires,
103
111
  # TODO: allow setting path in pyproject file?
@@ -112,4 +120,8 @@ class DevToolsConfig:
112
120
  pyproject_config.version_number_source
113
121
  ),
114
122
  disabled_extra_plugins=pyproject_config.disabled_extra_plugins,
123
+ license_file_path=pyproject_file_path.parent
124
+ / pyproject_config.license_file_path
125
+ if pyproject_config.license_file_path
126
+ else None,
115
127
  )
@@ -20,7 +20,7 @@
20
20
  import logging
21
21
  from dataclasses import dataclass, field
22
22
  from pathlib import Path
23
- from typing import Literal, Union
23
+ from typing import Literal, Optional, Union
24
24
 
25
25
  import tomli
26
26
 
@@ -43,6 +43,7 @@ class PyprojectConfig:
43
43
  Literal["changelog"], Literal["distribution"]
44
44
  ] = "changelog"
45
45
  disabled_extra_plugins: list[str] = field(default_factory=list)
46
+ license_file_path: Optional[str] = None
46
47
 
47
48
  def __post_init__(self) -> None:
48
49
  if self.version_number_source not in ["changelog", "distribution"]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qgis-plugin-dev-tools
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: QGIS plugin development and packaging tools, which make managing runtime dependencies easy.
5
5
  Home-page: https://github.com/nlsfi/qgis-plugin-dev-tools
6
6
  Author: National Land Survey of Finland
@@ -22,11 +22,11 @@ Classifier: Typing :: Typed
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE
25
- Requires-Dist: packaging >=21.0
26
- Requires-Dist: tomli >=2.0.0
27
- Requires-Dist: python-dotenv >=0.19.0
28
- Requires-Dist: importlib-metadata >=4.9.0
29
- Requires-Dist: requests >=2.27.0
25
+ Requires-Dist: packaging>=21.0
26
+ Requires-Dist: tomli>=2.0.0
27
+ Requires-Dist: python-dotenv>=0.19.0
28
+ Requires-Dist: importlib-metadata>=4.9.0
29
+ Requires-Dist: requests>=2.27.0
30
30
 
31
31
  # qgis-plugin-dev-tools
32
32
 
@@ -91,6 +91,14 @@ plugin_package_name = "your_plugin_package_name"
91
91
  version_number_source = "distribution" # or "changelog" (default if missing)
92
92
  ```
93
93
 
94
+ QGIS plugins are required to have a LICENSE file included in the plugin package. However, usually it is more convenient to keep the license file in the root of the repository. LICENSE can be copied automatically to the plugin zip while packaging if such file is found. A relative path to the license file can also be configured with `license_file_path` option.
95
+
96
+ ```toml
97
+ [tool.qgis_plugin_dev_tools]
98
+ plugin_package_name = "your_plugin_package_name"
99
+ license_file_path = "docs/my-license.md"
100
+ ```
101
+
94
102
  ## Plugin packaging
95
103
 
96
104
  Run `qgis-plugin-dev-tools build` (short `qpdt b`) to package the plugin and any runtime dependencies to a standard QGIS plugin zip file, that can be installed and published.
@@ -167,6 +175,10 @@ All notable changes to this project will be documented in this file.
167
175
 
168
176
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
169
177
 
178
+ ## [0.9.0] - 2025-01-08
179
+
180
+ - Feat: Copy license into the plugin zip while deploying
181
+
170
182
  ## [0.8.0] - 2024-08-23
171
183
 
172
184
  - Feat: Add locale and ui ini options to be able to further customize development environment
@@ -240,3 +252,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
240
252
  [0.6.2]: https://github.com/nlsfi/qgis-plugin-dev-tools/releases/tag/v0.6.2
241
253
  [0.7.0]: https://github.com/nlsfi/qgis-plugin-dev-tools/releases/tag/v0.7.0
242
254
  [0.8.0]: https://github.com/nlsfi/qgis-plugin-dev-tools/releases/tag/v0.8.0
255
+ [0.9.0]: https://github.com/nlsfi/qgis-plugin-dev-tools/releases/tag/v0.9.0
@@ -1,16 +1,16 @@
1
- qgis_plugin_dev_tools/__init__.py,sha256=EyLJdeFZiG9GjOkxlKxhB9yZDouz8kylbW5tBwmPCo4,1064
1
+ qgis_plugin_dev_tools/__init__.py,sha256=COQRV9RQ7IMaTRLFDWEzoEys0yRJp_kYVplfvn2UNsY,1064
2
2
  qgis_plugin_dev_tools/__main__.py,sha256=EqC7agwIoIKbMeOPrcpDWGAQmsaO_oFc0OkIxlowzmA,900
3
3
  qgis_plugin_dev_tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- qgis_plugin_dev_tools/build/__init__.py,sha256=RbPVZeH29y8efqZRO0dmnH1ArzRvhcpOj9Ka60plX8c,3514
4
+ qgis_plugin_dev_tools/build/__init__.py,sha256=JDxRaPtJfN08AnyKMB8dTc1b2oIFHZBvclyIZQGnCEA,3593
5
5
  qgis_plugin_dev_tools/build/changelog_parser.py,sha256=t9u30K2DyWXBOW47r2dMXzP-nbW7oIFCkYeBzsL8r_A,2212
6
6
  qgis_plugin_dev_tools/build/distribution.py,sha256=ST2h-YeVh8HWeDURhXoG_Rba9Zha167tdBlVJbXEdQQ,835
7
7
  qgis_plugin_dev_tools/build/metadata.py,sha256=rDKRDmvgJxsrlEWKnHNfq3gqOQxClgtNUeeKIIYyMos,1429
8
- qgis_plugin_dev_tools/build/packaging.py,sha256=ShLrWY_tGlf9orj865MzuET8VRJTpODgb1CPNvISosc,6714
8
+ qgis_plugin_dev_tools/build/packaging.py,sha256=9npf95qRZjAlETUKc98Zs3EHqcUP-GsxBjgqaxX6YYk,8721
9
9
  qgis_plugin_dev_tools/build/rewrite_imports.py,sha256=YZ3ORvm_7Gf6tBKqjqzp-BR-Q_CoIbIh7MlxRZIfPQA,5945
10
10
  qgis_plugin_dev_tools/cli/__init__.py,sha256=qv0rEGKSUpk9oskNZC0X-bqiZy715XKDWQS0YBloqWI,6230
11
- qgis_plugin_dev_tools/config/__init__.py,sha256=7l7Iyjst-pqLobiAO2bKLvkQFLVWoq4O_rny9lQvHp8,4678
11
+ qgis_plugin_dev_tools/config/__init__.py,sha256=H8mNa_lBiSxLtAvuW-J8adzhZHP3I7BijxuWh_uQAnM,5165
12
12
  qgis_plugin_dev_tools/config/dotenv.py,sha256=CmqPAIPCwRFS5gMuCePZuNAMwsjggCoXejA1Fpq5k8c,2647
13
- qgis_plugin_dev_tools/config/pyproject.py,sha256=QvhZIk4QQezKSmTm28IG_lHBIO59CUQmAUQNB78Gxa4,2383
13
+ qgis_plugin_dev_tools/config/pyproject.py,sha256=_JUJYU-ejo5zuYNeDdwdbC4bQZlhCvXkBtF_TUpdz0A,2437
14
14
  qgis_plugin_dev_tools/publish/__init__.py,sha256=PB0bUWl6vjDSlqPm92hw2Vtn1A3sqymm3pWgkWsPCOI,2081
15
15
  qgis_plugin_dev_tools/start/__init__.py,sha256=9eBCJnpLjE7bll2R_YljiTFj9Bq0NqaFGPOKC7DG274,2181
16
16
  qgis_plugin_dev_tools/start/config.py,sha256=n8MaHsY-21LVcNnxwTrg9k8Wo2jb03nCKta6OB9dN3s,1326
@@ -20,9 +20,9 @@ qgis_plugin_dev_tools/start/bootstrap/__init__.py,sha256=4FoIYBxXM7zgyaTM4gz5fGD
20
20
  qgis_plugin_dev_tools/start/bootstrap/template.py,sha256=KV2EgHSMxKzA7wbKaxYwPnn6c1f7D2Yrd1Qq_Huh6y0,12432
21
21
  qgis_plugin_dev_tools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  qgis_plugin_dev_tools/utils/distributions.py,sha256=Q2jZT44Iw8LIBNrf1X2thfCLiKu9yiu7joj0Pdxk-Oc,3215
23
- qgis_plugin_dev_tools-0.8.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
24
- qgis_plugin_dev_tools-0.8.0.dist-info/METADATA,sha256=AwVTjaFDZk27lJbFbpOXmLmmk0kaXPuMMKPKbBe_IF4,10783
25
- qgis_plugin_dev_tools-0.8.0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
26
- qgis_plugin_dev_tools-0.8.0.dist-info/entry_points.txt,sha256=RwM8y7cN8cRk003jpw-psB4DvifC5foZKSi04IDRBVw,109
27
- qgis_plugin_dev_tools-0.8.0.dist-info/top_level.txt,sha256=JjwWwRniudLz30UtQJgmIQDeS3HgU5VBgDlKYJhz-nQ,22
28
- qgis_plugin_dev_tools-0.8.0.dist-info/RECORD,,
23
+ qgis_plugin_dev_tools-0.9.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
24
+ qgis_plugin_dev_tools-0.9.0.dist-info/METADATA,sha256=Nl-hFjW6wbOksSx6e6KJ01vofSe27anxGemDM2n4IfE,11431
25
+ qgis_plugin_dev_tools-0.9.0.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
26
+ qgis_plugin_dev_tools-0.9.0.dist-info/entry_points.txt,sha256=RwM8y7cN8cRk003jpw-psB4DvifC5foZKSi04IDRBVw,109
27
+ qgis_plugin_dev_tools-0.9.0.dist-info/top_level.txt,sha256=JjwWwRniudLz30UtQJgmIQDeS3HgU5VBgDlKYJhz-nQ,22
28
+ qgis_plugin_dev_tools-0.9.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.1)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5