Skip to content

Commit

Permalink
migrate to pyproject.toml for world peace
Browse files Browse the repository at this point in the history
  • Loading branch information
ianardee committed Nov 12, 2024
1 parent 9b19623 commit ea75c60
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 91 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion mindee/version

This file was deleted.

5 changes: 1 addition & 4 deletions mindee/versions.py
Original file line number Diff line number Diff line change
@@ -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]}"

Expand Down
81 changes: 81 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,82 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "mindee"
authors = [
{name = "Mindee", email = "[email protected]"},
]
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 = [
Expand Down Expand Up @@ -26,6 +105,7 @@ warn_unreachable = true
module = "pypdfium2.*"
ignore_missing_imports = true


[tool.pylic]
safe_licenses = [
"Apache Software License",
Expand All @@ -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"
Expand Down
67 changes: 0 additions & 67 deletions setup.cfg

This file was deleted.

14 changes: 0 additions & 14 deletions setup.py

This file was deleted.

10 changes: 5 additions & 5 deletions tests/test_pkg_versions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""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", "")


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]

Expand Down

0 comments on commit ea75c60

Please sign in to comment.