From ea75c6096cfafa930a4d733d3ee5c0363f986666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ianar=C3=A9=20S=C3=A9vi?= Date: Tue, 12 Nov 2024 13:15:54 +0100 Subject: [PATCH] migrate to pyproject.toml for world peace --- .pre-commit-config.yaml | 5 +++ mindee/version | 1 - mindee/versions.py | 5 +-- pyproject.toml | 81 ++++++++++++++++++++++++++++++++++++++ setup.cfg | 67 ------------------------------- setup.py | 14 ------- tests/test_pkg_versions.py | 10 ++--- 7 files changed, 92 insertions(+), 91 deletions(-) delete mode 100644 mindee/version delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50fa2cfb..1ed9f208 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,11 @@ repos: "--ignore=D10,D212,D203,D401" ] + - repo: https://github.com/gitleaks/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks + - repo: https://github.com/PyCQA/pylint rev: v2.17.7 hooks: diff --git a/mindee/version b/mindee/version deleted file mode 100644 index 01b73abe..00000000 --- a/mindee/version +++ /dev/null @@ -1 +0,0 @@ -4.13.0 \ No newline at end of file diff --git a/mindee/versions.py b/mindee/versions.py index 435003e4..b90e2e07 100644 --- a/mindee/versions.py +++ b/mindee/versions.py @@ -1,9 +1,6 @@ -import os import sys -dir_path = os.path.dirname(os.path.realpath(__file__)) -with open(os.path.join(dir_path, "version"), "r", encoding="utf-8") as version_file: - __version__ = version_file.read().strip() +__version__ = "4.13.0" python_version = f"{sys.version_info[0]}.{sys.version_info[1]}" diff --git a/pyproject.toml b/pyproject.toml index 160764a2..6ad4a154 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,82 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "mindee" +authors = [ + {name = "Mindee", email = "opensource@mindee.com"}, +] +dynamic = ["version"] +description = "Mindee API helper library for Python" +readme = "README.md" +license = {file = "LICENSE"} +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "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", + "Operating System :: OS Independent", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "License :: OSI Approved :: MIT License", +] + +requires-python = ">=3.7" + +dependencies = [ + "pypdfium2>=4.0,<5", + "Pillow>=9.5.0", + "pytz>=2023.3", + "requests~=2.32.3", +] + +[project.urls] +Homepage = "https://www.mindee.com" +Documentation = "https://developers.mindee.com/docs/python-sdk" +Repository = "https://github.com/publicMindee/mindee-api-python" +Issues = "https://github.com/mindee/mindee-api-python/issues" +Changelog = "https://github.com/mindee/mindee-api-python/blob/main/CHANGELOG.md" + +[project.optional-dependencies] +dev = [ + "pylint==2.17.7", + "setuptools==51.3.3", + "pre-commit~=3.5.0", + "types-pytz>=2023.3", + "types-requests~=2.31", + "toml~=0.10.2", + "pytest~=7.4", + "pytest-cov~=4.1", +] +docs = [ + "sphinx~=5.3", + "sphinx_rtd_theme~=1.1", + "sphinx-autodoc-typehints~=1.20", +] +build = [ + "build", + "twine", +] + +[project.scripts] +mindee = "mindee.cli:main" + + +[tool.setuptools] +packages = ["mindee", ] + +[tool.setuptools.dynamic] +version = {attr = "mindee.versions.__version__"} + +[tool.setuptools.package-data] +"mindee" = ["py.typed"] + + [tool.black] line-length = 88 target-version = [ @@ -26,6 +105,7 @@ warn_unreachable = true module = "pypdfium2.*" ignore_missing_imports = true + [tool.pylic] safe_licenses = [ "Apache Software License", @@ -36,6 +116,7 @@ safe_licenses = [ "Historical Permission Notice and Disclaimer (HPND)" ] + [tool.pytest.ini_options] addopts = "--pyargs --cov mindee --cov-report term:skip-covered --cov-report term-missing -m 'not regression and not integration'" python_files = "test*.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 57c5f798..00000000 --- a/setup.cfg +++ /dev/null @@ -1,67 +0,0 @@ -[metadata] -name = mindee -author = Mindee -author_email = opensource@mindee.com -description = Mindee API helper library for Python -long_description = file:README.md -long_description_content_type = text/markdown -classifiers= - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - 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 - Operating System :: OS Independent - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Topic :: Software Development :: Libraries - License :: OSI Approved :: MIT License -url = https://mindee.com/ -project_urls = - Documentation = https://developers.mindee.com/docs/python-sdk - Source = https://github.com/publicMindee/mindee-api-python -license = MIT -license_files = LICENSE -platform = any - -[options] -zip_safe = False -packages = find: -include_package_data = True -python_requires = >=3.7 -install_requires = - pypdfium2>=4.0,<5 - Pillow>=9.5.0 - pytz>=2023.3 - requests~=2.31 - -[options.entry_points] -console_scripts = - mindee-cli = mindee.cli:main - -[options.package_data] -mindee = - version - py.typed - -[options.extras_require] -dev = - pylint==2.17.7 - setuptools==51.3.3 - pre-commit~=2.21.0 - types-pytz~=2023.3 - types-requests~=2.31 - pytest~=7.4 - pytest-cov~=4.1 -docs = - sphinx~=5.3 - sphinx_rtd_theme~=1.1 - sphinx-autodoc-typehints~=1.20 -build = - build - twine - -[options.packages.find] -exclude = tests diff --git a/setup.py b/setup.py deleted file mode 100644 index cfd3811d..00000000 --- a/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -"""Mindee module setup.""" - -import os - -from setuptools import setup - -dir_path = os.path.dirname(os.path.realpath(__file__)) -version_file = os.path.join(dir_path, "mindee", "version") -with open(version_file, "r", encoding="utf-8") as file_p: - __version__ = file_p.read().strip() - -setup( - version=__version__, -) diff --git a/tests/test_pkg_versions.py b/tests/test_pkg_versions.py index e9a1e4f3..67a20fbd 100644 --- a/tests/test_pkg_versions.py +++ b/tests/test_pkg_versions.py @@ -1,9 +1,10 @@ """Test to check if style packages are in same versions as pre-commit config.""" -import configparser import re from pathlib import Path +import toml + def _test_version(versions_a, versions_b, key): assert versions_a[key].replace("v", "") == versions_b[key].replace("v", "") @@ -11,11 +12,10 @@ def _test_version(versions_a, versions_b, key): def test_style_pkg_versions(): """Check black, flake8, isort and pydocstyle versions consistency.""" - config = configparser.ConfigParser() - config.read(Path(__file__).parent.parent.joinpath("setup.cfg")) - line_sep = re.compile(r"(==|~=)") + config = toml.load(Path(__file__).parent.parent.joinpath("pyproject.toml")) + line_sep = re.compile(r"(==|~=|>=)") requirements_versions = {} - for line in config["options.extras_require"]["dev"].split(): + for line in config["project"]["optional-dependencies"]["dev"]: split_line = line_sep.split(line.strip()) requirements_versions[split_line[0]] = split_line[2]