diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 56f8e78f..00000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,16 +0,0 @@ -[bumpversion] -current_version = 1.13.0 -commit = True -tag = True - -[bumpversion:file:docs/conf.py] -search = release = "{current_version}" -replace = release = "{new_version}" - -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" - -[bumpversion:file:craft_providers/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 74fcf0e7..0c88b2d8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -32,7 +32,7 @@ jobs: sudo snap install --no-wait shellcheck echo "::endgroup::" echo "::group::pip install" - python -m pip install -U .[dev] + python -m pip install -U .[dev,lint,types] echo "::endgroup::" echo "::group::Wait for snap to complete" snap watch --last=install diff --git a/craft_providers/__init__.py b/craft_providers/__init__.py index df8cab56..66ff2823 100644 --- a/craft_providers/__init__.py +++ b/craft_providers/__init__.py @@ -1,5 +1,5 @@ # -# Copyright 2021 Canonical Ltd. +# Copyright 2021-2023 Canonical Ltd. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,13 +17,21 @@ """Craft Providers base package.""" -__version__ = "1.13.0" - from .base import Base from .errors import ProviderError from .executor import Executor from .provider import Provider +try: + from ._version import __version__ +except ImportError: # pragma: no cover + from importlib.metadata import version, PackageNotFoundError + + try: + __version__ = version("craft_providers") + except PackageNotFoundError: + __version__ = "dev" + __all__ = [ "Base", "Executor", diff --git a/docs/conf.py b/docs/conf.py index 98fb32f2..884f5e56 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,5 @@ # -# Copyright 2021 Canonical Ltd. +# Copyright 2021-2023 Canonical Ltd. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -36,12 +36,9 @@ # -- Project information ----------------------------------------------------- project = "Craft Providers" -copyright = "2021, Canonical Ltd." +copyright = "2021-2023, Canonical Ltd." author = "Canonical Ltd." -# The full version, including alpha/beta/rc tags -release = "1.13.0" - # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 07c7b2f5..9fceb770 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,87 @@ +[project] +name = "craft-providers" +dynamic = ["version", "readme"] +dependencies = [ + "pydantic", + "pyyaml", + "requests_unixsocket", + # Needed until requests-unixsocket supports urllib3 v2 + # https://github.com/msabramo/requests-unixsocket/pull/69 + "urllib3<2", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", + "Natural Language :: English", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", +] +requires-python = ">=3.8" + +[project.scripts] +craft-providers = "craft_providers.cli:main" + +[project.optional-dependencies] +dev = [ + "twine", + "coverage", + "freezegun", + "logassert", + "pyfakefs", + "pytest", + "pytest-mock", + "pytest-subprocess", + "responses", + "types-requests", + "types-setuptools", + "types-pyyaml", +] +lint = [ + "black", + "codespell", + "ruff==0.0.270", + "yamllint", +] +types = [ + "mypy", + "pyright", +] +docs = [ + "sphinx", + "sphinx-autodoc-typehints", + "sphinx-pydantic", + "sphinx-rtd-theme", +] + +[build-system] +requires = [ + "setuptools==67.7.2", + "setuptools_scm[toml]>=7.1" +] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +readme = {file = "README.md"} + +[tool.setuptools_scm] +write_to = "craft_providers/_version.py" + +[tool.setuptools.packages.find] +exclude = [ + "dist", + "docs", + "results", + "tests", +] + + + [tool.distutils.bdist_wheel] universal = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 627e0232..00000000 --- a/setup.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2021-2022 Canonical Ltd. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License version 3 as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# - - -"""The setup script.""" - -from setuptools import find_packages, setup # type: ignore - -with open("README.md") as readme_file: - readme = readme_file.read() - -install_requires = [ - "pydantic", - "pyyaml", - "requests_unixsocket", - # Needed until requests-unixsocket supports urllib3 v2 - # https://github.com/msabramo/requests-unixsocket/pull/69 - "urllib3<2", -] - -dev_requires = [ - "twine", -] - -doc_requires = [ - "sphinx", - "sphinx-autodoc-typehints", - "sphinx-pydantic", - "sphinx-rtd-theme", -] - -test_requires = [ - "coverage", - "black", - "codespell", - "freezegun", - "mypy", - "logassert", - "pyfakefs", - "pytest", - "pytest-mock", - "pytest-subprocess", - "responses", - "ruff==0.0.270", - "types-requests", - "types-setuptools", - "types-pyyaml", - "yamllint", -] - -extras_requires = { - "dev": dev_requires + test_requires, - "doc": doc_requires, - "test": test_requires, -} - -setup( - name="craft-providers", - version="1.13.0", - description="Craft provider tooling", - long_description=readme, - long_description_content_type="text/markdown", - author="Canonical Ltd.", - author_email="snapcraft@lists.snapcraft.io", - url="https://github.com/canonical/craft-providers", - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Natural Language :: English", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], - license="GNU Lesser General Public License v3 (LGPLv3)", - python_requires=">=3.8", - packages=find_packages(include=["craft_providers", "craft_providers.*"]), - entry_points={ - "console_scripts": [ - "craft_providers=craft_providers.cli:main", - ], - }, - install_requires=install_requires, - extras_require=extras_requires, - package_data={"craft_providers": ["py.typed"]}, - include_package_data=True, - zip_safe=False, -)