diff --git a/Makefile b/Makefile index cbf87e67..e0edf8e7 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,9 @@ export PODMAN_VERSION ?= "5.3.0" .PHONY: podman podman: rm dist/* || : - $(PYTHON) -m pip install --user -r requirements.txt + $(PYTHON) -m pip install -q build PODMAN_VERSION=$(PODMAN_VERSION) \ - $(PYTHON) setup.py sdist bdist bdist_wheel + $(PYTHON) -m build .PHONY: lint lint: tox diff --git a/README.md b/README.md index f2ffee71..b7b641d4 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,9 @@ pip install podman ## Dependencies -* For runtime dependencies, see [requirements.txt](https://github.com/containers/podman-py/blob/main/requirements.txt). -* For testing and development dependencies, see [test-requirements.txt](https://github.com/containers/podman-py/blob/main/test-requirements.txt). +* For runtime dependencies, see \[dependencies\] in [pyproject.toml](https://github.com/containers/podman-py/blob/main/pyproject.toml) +* For testing and development dependencies, see \[project.optional.dependencies\] in [pyproject.toml](https://github.com/containers/podman-py/blob/main/pyproject.toml) + * The package is split in \[progress\_bar\], \[docs\], and \[test\] ## Example usage diff --git a/plans/main.fmf b/plans/main.fmf index 06e46b52..a5b13888 100644 --- a/plans/main.fmf +++ b/plans/main.fmf @@ -20,7 +20,7 @@ prepare: - name: pip dependencies how: shell script: - - pip3 install -r test-requirements.txt + - pip3 install .[test] - name: ssh configuration how: shell diff --git a/pyproject.toml b/pyproject.toml index 5361b2fd..fe9757ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,32 +1,128 @@ -[tool.black] -line-length = 100 -skip-string-normalization = true -preview = true -target-version = ["py39"] -include = '\.pyi?$' -exclude = ''' -/( - \.git - | \.tox - | \.venv - | \.history - | build - | dist - | docs - | hack -)/ -''' -[tool.isort] -profile = "black" -line_length = 100 [build-system] -# Any changes should be copied into requirements.txt, setup.cfg, and/or test-requirements.txt -requires = [ - "setuptools>=46.4", -] +requires = ["setuptools>=46.4"] build-backend = "setuptools.build_meta" + +[project] +name = "podman" +dynamic = ["version"] +description = "Bindings for Podman RESTful API" +readme = "README.md" +license = {file = "LICENSE"} +requires-python = ">=3.9" +authors = [ + { name = "Brent Baude" }, + { name = "Jhon Honce", email = "jhonce@redhat.com" }, + { name = "Urvashi Mohnani" }, + { name = "Nicola Sella", email = "nsella@redhat.com" }, +] +keywords = [ + "libpod", + "podman", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Software Development :: Libraries :: Python Modules", +] +# compatible releases +# ~= with version numbers +dependencies = [ + "requests >=2.24", + "tomli>=1.2.3; python_version<'3.11'", + "urllib3", +] + +[project.optional-dependencies] +progress_bar = [ + "rich >= 12.5.1", +] +docs = [ + "sphinx" +] +test = [ + "coverage", + "fixtures", + "pytest", + "requests-mock", +] + +[project.urls] +"Bug Tracker" = "https://github.com/containers/podman-py/issues" +Homepage = "https://github.com/containers/podman-py" +"Libpod API" = "https://docs.podman.io/en/latest/_static/api.html" + [tool.pytest.ini_options] log_cli = true log_cli_level = "DEBUG" log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)" log_cli_date_format = "%Y-%m-%d %H:%M:%S" + +[tool.setuptools] +packages = ["podman"] + +[tool.setuptools.dynamic] +version = {attr = "podman.version.__version__"} + +[tool.ruff] +line-length = 100 +src = ["podman"] + +# This is the section where Black is mostly replaced with Ruff +[tool.ruff.format] +exclude = [ + ".git", + ".history", + ".tox", + ".venv", + "build", + "dist", + "docs", + "hack", +] +quote-style = "preserve" + +[tool.ruff.lint] +select = [ + # More stuff here https://docs.astral.sh/ruff/rules/ + "F", # Pyflakes + "E", # Pycodestyle Error + "W", # Pycodestyle Warning + "N", # PEP8 Naming + # TODO "UP", # Pyupgrade + # TODO "ANN", + # TODO "S", # Bandit + # "B", # Bugbear + "A", # flake-8-builtins + "YTT", # flake-8-2020 + "PLC", # Pylint Convention + "PLE", # Pylint Error + "PLW", # Pylint Warning +] +# Some checks should be enabled for code sanity disabled now +# to avoid changing too many lines +ignore = [ + "F821", # TODO Undefined name + "F541", # TODO f-string is missing placeholders + "F401", # TODO Module imported but unused + "F841", # TODO Local variable is assigned to but never used + "E402", # TODO Module level import not at top of file + "E741", # TODO ambiguous variable name + "E722", # TODO do not use bare 'except' + "E501", # TODO line too long + "N818", # TODO Error Suffix in exception name + "N80", # TODO Invalid Name + "ANN10", # Missing type annotation + "PLW2901", # TODO Redefined Loop Name +] +[tool.ruff.lint.flake8-builtins] +builtins-ignorelist = ["copyright", "all"] +[tool.ruff.lint.per-file-ignores] +"podman/tests/*.py" = ["S"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index f16a9878..00000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Any changes should be copied into pyproject.toml -requests>=2.24 -setuptools -sphinx -tomli>=1.2.3; python_version<'3.11' -urllib3 -wheel diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 8b83a5ba..00000000 --- a/ruff.toml +++ /dev/null @@ -1,97 +0,0 @@ -line-length = 100 -[format] -exclude = [ - ".git", - ".venv", - ".history", - "build", - "dist", - "docs", - "hack", -] -quote-style = "preserve" -[lint] -select = [ - # More stuff here https://docs.astral.sh/ruff/rules/ - "F", # Pyflakes - "E", # Pycodestyle Error - "W", # Pycodestyle Warning - # "I", # isort # some opinions here and there but probably autofixable - "N", # PEP8 Naming - # "D", # pydocstyle # Lots of errors but we definitely need to improve this - "UP", # Pyupgrade - "YTT", # flake-8-2020 - # TODO "ANN", - "ASYNC", # flake8-async - "S", # Bandit - # "BLE", # flake8-blind-except # One simple fix - # "FBT", # flake8-boolean-trap # ~30 issues that can be fixed if the API does not break - "B", # Bugbear - "A", # flake-8-builtins - # "COM", # flake8-commas # many, many, autofixes - # "CPY", # flake8-copyright - # "C4", # flake8-comprehensions # trivial fixes - # "DTZ", # flake8-datetimez # Couple of errors here - "T10", # flake8-debugger - # "DJ", # flake8-django # Useless - # "EM", # flake8-errmsg # Fixes are many but should be easy - "EXE", # flake8-executable - # "FA", # flake9-future-annotations # Things are breaking... - # "ISC", # flake8-implicit-str-concat # Couple of concats, easy fix - "ICN", # flake8-import-conventions - "LOG", # flake8-logging - # "G", # flake8-logging-format # Just one fix - # "INP", # flake8-no-pep420 # one fix - "PIE", # flake8-pie - # "T20", # flake8-print # Print should not be around - # "PYI", # flake8-pyi # Just two easy fixes - # "PT", # flake8-pytest-style # This is tricky and it makes ~500 errors that are not easy to fix - # "Q", # flake8-quotes # Probably ignored or fixed as last - # "Q003", # avoidable-escaped-quote # One simple fix - "Q004", # unnecessary-escaped-quote - # "RSE", # flake8-raise # One simple fix - "RET", # flake8-return - "SLF", # flake8-self - "SLOT", # flake8-slots - # "SIM", # flake8-simplify # Tricky, 80 reworks are to do - # "TID", # flake8-tidy-imports # a couple of imports are flaky - "TC", # flake8-type-checking - "INT", # flake8-gettext - # "ARG", # flake8-unused-arguments # 27 not simple errors - # "PTH", # flake8-use-pathlib # Opinionated but reasonable open->Path.open fix - # "TD", # flake8-todo # better todos, optional but nice to have for future sanity - # "FIX", # flake8-fixme # For the same reason of todos, this is really nice to have for sanity - # "ERA", # eradicate # Sometimes commented out code is about documentation - # "PGH", # pygrep-hooks # One single error but maybe not simple - # "PL", # Pylint # is aliasing the following - "PLC", # Pylint Convention - # "PLR", # Pylint Refactor # ~30 ish errors - "PLW", # Pylint Warning - "PLE", # Pylint Error - "PLW", # Pylint Warning - # "TRY", # tryceratops # Exception handling, not easy fixes - "FLY", # flynt - # "PERF", # perflint # few fixes - "FURB", # refurb - "DOC", # pydoclint - # "RUF", # ruff # some opinions here and there... need to think about it -] -# Some checks should be enabled for code sanity disabled now -# to avoid changing too many lines -ignore = [ - "F821", # TODO Undefined name - # Some Exceptions such as NotFound and NotFoundError can be ambiguous - # This change need to be performed with carefulness - "N818", # TODO Error Suffix in exception name - # This can lead to API breaking changes so it's disabled for now - "N80", # TODO Invalid Name - # TODO this error fails on one file and it's necessary to address - # the issue properly on a specific PR - "S108", - # TODO This is probably a false positive - "S603", -] -[lint.per-file-ignores] -"podman/tests/*.py" = ["S"] -[lint.flake8-builtins] -builtins-ignorelist = ["copyright", "all"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d31a2479..00000000 --- a/setup.cfg +++ /dev/null @@ -1,52 +0,0 @@ -[metadata] -name = podman -version = 5.3.0 -author = Brent Baude, Jhon Honce, Urvashi Mohnani, Nicola Sella -author_email = jhonce@redhat.com -description = Bindings for Podman RESTful API -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/containers/podman-py -license = Apache-2.0 -license_files = LICENSE -platforms = any -project_urls = - Bug Tracker = https://github.com/containers/podman-py/issues - Libpod API = https://docs.podman.io/en/latest/_static/api.html -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: Apache Software License - Operating System :: OS Independent - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3.13 - Topic :: Software Development :: Libraries :: Python Modules -keywords = podman, libpod - -[options] -include_package_data = True -python_requires = >=3.9 -test_suite = -# Any changes should be copied into pyproject.toml -install_requires = - requests >=2.24 - tomli>=1.2.3; python_version<'3.11' - urllib3 - -[options.extras_require] -progress_bar = - rich >= 12.5.1 - -# typing_extensions are included for RHEL 8.5 -# typing_extensions;python_version<'3.8' - -[bdist_wheel] -# python < 3.6 not supported -universal = false - -[sdist] -formats = gztar diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 1a70e359..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Any changes should be copied into pyproject.toml --r requirements.txt -ruff -coverage -fixtures -pytest -requests-mock >= 1.11.0 -tox diff --git a/tox.ini b/tox.ini index 25169f8c..e69da23b 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,7 @@ ignore_basepython_conflict = true [testenv] basepython = python3 usedevelop = True -install_command = pip install {opts} {packages} -deps = -r{toxinidir}/test-requirements.txt +deps = .[test] commands = pytest {posargs} setenv = PODMAN_LOG_LEVEL = {env:PODMAN_LOG_LEVEL:INFO}