-
Notifications
You must be signed in to change notification settings - Fork 512
Expand file tree
/
Copy pathpyproject.toml
More file actions
419 lines (388 loc) · 13.5 KB
/
pyproject.toml
File metadata and controls
419 lines (388 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
[project]
name = "snapcraft"
description = "Create snaps"
dynamic = ["version"]
dependencies = [
"attrs",
"catkin-pkg==1.1.0; sys_platform == 'linux'",
"click>=8.2",
"craft-application[remote]>=6.2.0",
"craft-archives>=2.2.0",
"craft-cli>=3.3.0",
"craft-grammar>=2.3.0",
"craft-parts>=2.28.0",
"craft-platforms>=0.10.0",
"craft-providers>=3.3.0",
"craft-store>=3.3.0",
"cryptography",
"gnupg",
"jsonschema==2.6.0",
"launchpadlib",
"lazr.restfulclient",
"lxml",
"macaroonbakery",
"mypy-extensions",
"overrides",
"packaging",
"progressbar",
"pydantic~=2.8",
"pyelftools",
# Pygit2 and libgit2 need to match versions.
# Further info: https://www.pygit2.org/install.html#version-numbers
# 1.18 is the last minor version that supports Python 3.10
"pygit2~=1.18.2",
# Snapcraft directly only cares about pylxd on Linux. However, as a note for
# packagers: As of 3.1.0, craft-providers depends on pylxd on all platforms.
# If we drop the direct dependency we will remove the following line, but pylxd
# will still be in the dependency tree.
"pylxd",
"python-debian ; sys_platform == 'linux'",
"pyxdg",
"pyyaml",
"raven",
"requests-toolbelt",
"requests-unixsocket2",
"requests>=2.32.4",
# setuptools >= 80.9 has a noisy warning about pkg_resources
"setuptools>=69.0,<80.9.0",
"simplejson",
"snap-helpers",
"tabulate",
"toml",
"tinydb",
"typing-extensions",
"validators>=0.28.3",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Operating System :: POSIX :: Linux",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Natural Language :: English",
"Topic :: Software Development :: Build Tools",
"Topic :: System :: Software Distribution",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
]
license-files = ["LICENSE"]
requires-python = ">=3.10"
readme = { file = "README.md", content-type = "text/markdown" }
[dependency-groups]
dev = [
"coverage[toml]",
"pyflakes",
"fixtures",
"mccabe",
"testscenarios",
"pexpect",
"pip",
"pycodestyle",
"pyftpdlib",
"pyinstaller ; sys_platform == 'win32'",
"pymacaroons",
"pyramid",
"pytest",
"pytest-cov",
"pytest-check",
"pytest-mock",
"pytest-subprocess",
]
docs = [
"pydantic-kitbash~=1.0",
"sphinx-pydantic==0.1.1",
"sphinx-lint~=1.0",
"sphinxext-rediraffe==0.3.0",
"sphinx-substitution-extensions==2025.1.2",
"sphinx-terminal==0.1.1",
"sphinx-copybutton",
{include-group = "docs-starter-pack"},
]
# We disable the unused but default SP dependencies slated for removal
# https://warthogs.atlassian.net/browse/DOCPR-2387
docs-starter-pack = [
"canonical-sphinx~=0.6",
"myst-parser>=4.0.1",
"packaging>=25.0",
"rst2html>=2020.7.4",
"sphinx-autobuild>=2024.10.3",
# "sphinx-config-options>=0.1.0",
# "sphinx-contributor-listing>=0.1.0",
"sphinx-design>=0.6.1",
# "sphinx-filtered-toctree>=0.1.0",
# "sphinx-last-updated-by-git>=0.3.8",
"sphinx-notfound-page>=1.1.0",
"sphinx-related-links>=0.1.1",
"sphinx-roles>=0.1.0",
"sphinx-sitemap>=2.6.0",
# "sphinx-tabs>=3.4.5",
# Ignore due to deps in Craft Parts
# "sphinx-terminal>=1.0.2",
# "sphinx-ubuntu-images>=0.1.0",
# "sphinx-youtube-links>=0.1.0",
"sphinxcontrib-jquery>=4.1",
# "sphinxcontrib-svg2pdfconverter[cairosvg]>=2.0.0",
"sphinxext-opengraph>=0.13.0",
"vale>=3.13.0.0",
]
lint = ["codespell[toml]", { include-group = "types" }]
types = [
"mypy~=1.19.0",
"types-PyYAML",
"types-requests>=2.32",
"types-setuptools",
"types-simplejson",
"types-tabulate",
"types-toml",
"types-lxml",
]
dev-jammy = ["python-apt~=2.4.0;sys_platform=='linux'"]
dev-noble = ["python-apt~=2.7.0;sys_platform=='linux'"]
dev-plucky = ["python-apt~=2.9.0;sys_platform=='linux'"]
dev-questing = ["python-apt~=3.0.0;sys_platform=='linux'"]
dev-resolute = ["python-apt~=3.0.0;sys_platform=='linux'"]
tics = ["flake8", "pylint"]
[tool.uv]
conflicts = [
[
{ group = "dev-jammy" },
{ group = "dev-noble" },
{ group = "dev-plucky" },
{ group = "dev-questing" },
{ group = "dev-resolute" },
],
]
constraint-dependencies = [
# pynacl did a breaking change from 1.5.0 to 1.6.0, bumping libsodium higher than
# what is available in the noble repositories.
# https://pynacl.readthedocs.io/en/latest/changelog/
# https://github.com/canonical/snapcraft/issues/5968
"pynacl<1.6.0",
# protobuf 6.33.x segfaults on s390x
# this issue might be the cause: https://github.com/protocolbuffers/protobuf/issues/24103
"protobuf==6.32.*",
]
build-constraint-dependencies = [
# needed until we have rustc >= 1.78
"maturin<1.10.0 ; python_version < '3.14'",
]
[[tool.uv.index]]
name = "python-apt-wheels"
url = "https://people.canonical.com/~lengau/python-apt-ubuntu-wheels/" # workaround to get python-apt to install across multiple platforms
explicit = true
[tool.uv.sources]
python-apt = { index = "python-apt-wheels" }
[project.scripts]
snapcraft = "snapcraft.application:main"
[build-system]
requires = ["setuptools>=69.0", "setuptools_scm[toml]>=7.1"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
script-files = ["bin/snapcraftctl", "bin/snapcraftctl-compat"]
[tool.setuptools_scm]
write_to = "snapcraft/_version.py"
# the version comes from the latest annotated git tag formatted as 'X.Y.Z'
# version scheme:
# - X.Y.Z.post<commits since tag>+g<hash>.d<%Y%m%d>
# parts of scheme:
# - X.Y.Z - most recent git tag
# - post<commits since tag>+g<hash> - present when current commit is not tagged
# - +dirty - present when working dir is dirty
# version scheme when no tags exist:
# - 0.0.post<total commits>+g<hash>
version_scheme = "post-release"
# deviations from the default 'git describe' command:
# - only match annotated tags
# - only match tags formatted as 'X.Y.Z'
git_describe_command = [
"git",
"describe",
"--dirty",
"--long",
"--match",
"[0-9]*.[0-9]*.[0-9]*",
"--exclude",
"*[^0-9.]*",
]
# Appends "+dirty" to the version when working dir is dirty
# Necessary to avoid version numbers being too long
local_scheme = "dirty-tag"
[tool.setuptools.packages.find]
include = ["snapcraft", "extensions", "keyrings", "schema", "snapcraft_legacy"]
namespaces = true
[tool.setuptools.package-data]
snapcraft = ["templates/*"]
[tool.mypy]
python_version = "3.10"
ignore_missing_imports = true
follow_imports = "silent"
exclude = [
"build",
"snapcraft_legacy",
"tests/spread",
"tests/legacy",
"tools",
"venv",
]
plugins = ["pydantic.mypy"]
[tool.pyright]
include = ["snapcraft", "tests"]
exclude = ["build", "tests/legacy", "tests/spread"]
pythonVersion = "3.10"
# Most of this ruff configuration comes from craft-parts
[tool.ruff]
target-version = "py310"
line-length = 88
extend-exclude = [
"docs",
"__pycache__",
"snapcraft_legacy",
"tests/legacy",
"snapcraft/_version.py", # setuptools_scm generates old-style type annotations and single quotes
]
lint.select = [
"E",
"F", # The rules built into Flake8
"I", # isort checking
"PLC",
"PLE",
"PLR",
"PLW", # Pylint
# Additional stricter checking than previously enabled:
"A", # Shadowing built-ins.
"W", # PyCodeStyle warnings.
"N", # Pep8 naming
"YTT", # flake8-2020: Misuse of `sys.version` and `sys.version_info`
"ANN", # Annotations
"S", # Checks for common security issues
"BLE", # Blind exception
"B", # Opinionated bugbear linting
"C4", # better comprehensions
"T10", # Ensure we don't leave code that starts the debugger in
"ICN", # Unconventional import aliases.
"Q", # Consistent quotations
"RET", # Return values
"UP", # pyupgrade
"TC001", # Checks for first-party imports that are only used for type annotations
"TC002", # Checks for third-party imports that are only used for type annotations
"TC003", # Checks for standard library imports that are only used for type annotations
"TC004", # Remove imports from type-checking guard blocks if used at runtime
"TC005", # Delete empty type-checking blocks
]
lint.ignore = [
# These following copy the flake8 configuration
#"E203", # Whitespace before ":" -- Commented because ruff doesn't currently check E203
"E501", # Line too long (reason: ruff will automatically fix this for us)
# The following copy our pydocstyle configuration
"D105", # Missing docstring in magic method (reason: magic methods already have definitions)
"D107", # Missing docstring in __init__ (reason: documented in class docstring)
"D203", # 1 blank line required before class docstring (reason: pep257 default)
"D213", # Multi-line docstring summary should start at the second line (reason: pep257 default)
"D215", # Section underline is over-indented (reason: pep257 default)
"PLW1641", # eq-without-hash (most of our classes should be unhashable)
# Ignored due to conflicts with ruff's formatter:
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"COM812", # Missing trailing comma - mostly the same, but marginal differences.
"ISC001", # Single-line implicit string concatenation.
# Stricter type checking rules that that are disabled.
"A003", # Class attribute shadowing a python built-in (class attributes are seldom if ever referred to bare)
"N818", # Exception names ending with suffix `Error`
"ANN002",
"ANN003", # Missing type annotation for *args and **kwargs
"ANN204", # Missing type annotations for magic methods
"ANN401", # Disallowing `typing.Any`
"B904", # Within an except clause, always explicitly `raise` an exception `from` something.
"B905", # Zip without explicit `strict=` parameter - this only exists in 3.10+
# Disabled because the current code breaks these rules without "noqa" comments
# Most of these are probably worth enabling eventually.
# Annotation issues appear to be mostly in older code, so could be eventually enabled.
# 5 instances of ANN201, 10 instances of ANN202
"ANN201",
"ANN202", # Missing return type annotation for public/private function
# 13 instances of ANN206 - probably mostly :noqa-able
"ANN206",
# Comprehensions - IDK, these ones flagged and they really could go either way.
"C405",
"C408",
"C414",
"RET504",
"RET506", # Return value related.
"PLR2004", # Magic values - widely used
"S603", # Untrusted input for subprocess calls
"S604", # shell=True parameter to a function
"S607", # Partial executable path for subprocess calls
]
[tool.ruff.lint.per-file-ignores]
"tests/**.py" = [ # Some things we want for the main project are unnecessary in tests.
"D", # Ignore docstring rules in tests
"ANN", # Ignore type annotations in tests
"ARG", # Allow unused arguments in tests (e.g. for fake functions/methods/classes)
"S101", # Allow assertions in tests
"S103", # Allow `os.chmod` setting a permissive mask `0o555` on file or directory
"S105", # Allow Possible hardcoded password.
"S106", # Allow Possible hardcoded password.
"S108", # Allow Probable insecure usage of temporary file or directory
"PLR0913", # Allow many arguments for test functions (useful if we need many fixtures)
"PLR2004", # Allow magic values in tests
"SLF", # Allow accessing private members from tests.
]
"tests/unit/parts/plugins/test_kernel.py" = [
"E101", # Mixed tabs and spaces. Ruff gets confused by tabs in multiline strings
]
"__init__.py" = [
"I001", # isort leaves init files alone by default, this makes ruff ignore them too.
"F401", # Allows unused imports in __init__ files.
]
[tool.ruff.lint.flake8-annotations]
allow-star-arg-any = true
[tool.ruff.lint.flake8-builtins]
strict-checking = true
[tool.ruff.lint.pydocstyle]
ignore-decorators = [ # Functions with these decorators don't have to have docstrings.
"typing.overload", # Default configuration
# The next four are all variations on override, so child classes don't have to repeat parent classes' docstrings.
"overrides.override", # Used in snapcraft_legacy
"overrides.overrides", # Used in snapcraft_legacy
"typing.override",
"typing_extensions.override",
]
[tool.ruff.lint.pylint]
max-args = 8
max-branches = 16
[tool.ruff.lint.pep8-naming]
# Allow Pydantic's `@validator` decorator to trigger class method treatment.
classmethod-decorators = ["pydantic.validator", "pydantic.root_validator"]
[tool.ty.src]
exclude = [
"build",
"snapcraft_legacy",
"tests/spread",
"tests/legacy",
"tools",
"venv",
]
[tool.ty.rules]
# Temporarily disabled while mypy and pyright are still in use.
# See: https://github.com/canonical/snapcraft/issues/6007
unused-type-ignore-comment = "ignore"
[tool.pytest.ini_options]
minversion = "7.0"
testpaths = "tests"
xfail_strict = true
addopts = "--ignore=tests/spread"
markers = ["slow: slow tests"]
[tool.coverage.run]
branch = true
omit = ["test/**"]
[tool.coverage.report]
skip_empty = true
exclude_also = ["if (typing\\.)?TYPE_CHECKING:"]
[tool.codespell]
ignore-words-list = ["buildd", "crate", "assertIn", "socio-economic"]
skip = [
# Keyrings aren't code
"*.asc",
# These tests include some non-English text
"*/test_appstream.py",
"*/test_update_metadata.py",
]