Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate to pyproject.toml #902

Merged
merged 7 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .bumpversion.cfg

This file was deleted.

15 changes: 13 additions & 2 deletions craft_parts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

"""Craft a project from several parts."""

__version__ = "2.1.4"

from . import plugins
from .actions import Action, ActionProperties, ActionType
from .dirs import ProjectDirs
Expand All @@ -35,7 +33,20 @@
)
from .steps import Step


try:
from ._version import __version__
except ImportError: # pragma: no cover
from importlib.metadata import version, PackageNotFoundError

try:
__version__ = version("craft_parts")
except PackageNotFoundError:
__version__ = "dev"


__all__ = [
"__version__",
"Features",
"Action",
"ActionProperties",
Expand Down
187 changes: 186 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,178 @@
[project]
name = "craft-parts"
dynamic = ["version"]
description = "Craft parts tooling"
readme = "README.md"
requires-python = ">=3.10"
authors = [
{ name = "Canonical Ltd.", email = "snapcraft@lists.snapcraft.io" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Natural Language :: English",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"overrides!=7.6.0",
"pydantic>=2.0.0",
"pyxdg",
"PyYAML",
"requests-unixsocket2>=0.4.0",
"requests>=2.32,<3.0",
]

[project.optional-dependencies]
apt = [
"python-apt>=2.4.0;sys_platform=='linux'"
]
docs = [
"canonical-sphinx",
"sphinx",
"sphinx-autodoc-typehints",
"sphinx-lint",
"sphinx-pydantic",
"sphinx-rtd-theme",
"sphinxcontrib-details-directive",
]
dev = [ # TODO: Remove this once we've switched CI to uv
# Inherited from starbase
"build",
"coverage[toml]~=7.4",
"pytest~=8.0",
"pytest-cov~=5.0",
"pytest-mock~=3.12",
"yamllint~=1.34",
"mypy[reports]~=1.11.0",
"pyright==1.1.388",
"types-Pygments",
"types-colorama",
"types-setuptools",

# Project-specific linting
"autoflake",
"black",
"codespell",
"pydocstyle",
"tox",

# Testing
"hypothesis",
"jsonschema",
"pytest-check",
"pytest-subprocess",
"requests-mock",

# Type checking
"types-colorama",
"types-docutils",
"types-jsonschema",
"types-Pillow",
"types-Pygments",
"types-pytz",
"types-PyYAML",
"types-requests",
"types-setuptools",
]

[tool.uv]
constraint-dependencies = [
# Basic constraints to allow --resolution=lowest
"build>=0.7.0",
"iniconfig>=1.1.0",
"lxml>=5.0",
"pyparsing>=3.0.0",
"pyproject-hooks>=1.0.0",
"pyyaml>=5.0",
"markdown>=3.0",
"markupsafe>=2.0",
"pyyaml>5.0",
"regex>=2021.11.10",
"sphinx-basic-ng>=1.0.0b1",
"tornado>=4.0",
"webencodings>=0.4.0",
]
dev-dependencies = [
# Inherited from starbase
"build",
"coverage[toml]~=7.4",
"pytest~=8.0",
"pytest-cov~=5.0",
"pytest-mock~=3.12",
"yamllint~=1.35",
"mypy[reports]~=1.11.0",
"pyright==1.1.388",
"types-Pygments",
"types-colorama",
"types-setuptools",

# Project-specific linting
"autoflake",
"black",
"codespell",
"pydocstyle",

# Testing
"hypothesis",
"jsonschema",
"pytest-check",
"pytest-subprocess",
"requests-mock",

# Type checking
"types-colorama",
"types-docutils",
"types-jsonschema",
"types-Pillow",
"types-Pygments",
"types-pytz",
"types-PyYAML",
"types-requests",
"types-setuptools",
]


[project.scripts]
craftctl = "craft_parts.ctl:main"

[project.urls]
Homepage = "https://github.com/canonical/craft-parts"

[build-system]
requires = [
"setuptools>=69.0",
"setuptools_scm[toml]>=7.1"
]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-dir]
"craft_parts" = "craft_parts"
"craft_parts_docs" = "docs/common"


[tool.setuptools.dynamic]
readme = {file = "README.rst"}

[tool.setuptools_scm]
write_to = "craft_parts/_version.py"
tigarmo marked this conversation as resolved.
Show resolved Hide resolved
# 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
# - .d<%Y%m%d> - 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.]*'"

[tool.black]
target-version = ["py310"]

Expand All @@ -7,7 +182,6 @@ skip = ".tox,.git,build,.*_cache,__pycache__,*.tar,*.snap,*.png,./node_modules,.
quiet-level = 3
check-filenames = true


[tool.mypy]
python_version = "3.10"
exclude = [
Expand Down Expand Up @@ -37,6 +211,17 @@ no_implicit_optional = true
module = ["tests.*"]
strict = false

[tool.pydocstyle]
ignore = [
"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)
"D204",
"D213", # Multi-line docstring summary should start at the second line (reason: pep257 default)
"D215", # Section underline is over-indented (reason: pep257 default)
]


[tool.ruff]
line-length = 88
target-version = "py310"
Expand Down
20 changes: 0 additions & 20 deletions setup.cfg

This file was deleted.

Loading
Loading