diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4e1ef42..9b97706 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -21,11 +21,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2e4905b..80f702b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -9,11 +9,15 @@ The source code, located at `the ColorDetect project page `_ for dependency management. +Install it via:: - python3 -m venv .venv - .venv/bin/activate - pip install -r requirements/requirements-dev.txt + curl -LsSf https://astral.sh/uv/install.sh | sh + +Then set up the project:: + + uv venv + uv pip install -e ".[dev]" pre-commit install diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..271594f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,41 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "ColorDetect" +version = "1.6.3" +authors = [ + {name = "Marvin Kweyu", email = "mkweyu1@gmail.com"}, +] +description = "Detect and recognize colors in images or video" +readme = "README.md" +license = {text = "MIT"} +requires-python = ">=3.6" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: POSIX :: Linux", +] +dependencies = [ + "numpy>=1.18.1", + "matplotlib>=3.2.1", + "opencv-python>=4.2.0.32", + "scikit-learn>=0.22.2.post1", + "webcolors>=1.11.1", +] + +[project.urls] +Homepage = "https://github.com/MarvinKweyu/ColorDetect" + +[project.optional-dependencies] +dev = [ + "pytest", + "flake8", + "black", + "isort", + "pre-commit", +] + +[tool.setuptools.packages.find] +where = ["."] diff --git a/setup.py b/setup.py deleted file mode 100644 index a811c05..0000000 --- a/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="ColorDetect", - version="1.6.3", - author="Marvin Kweyu", - author_email="mkweyu1@gmail.com", - description="Detect and recognize colors in images or video", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/MarvinKweyu/ColorDetect", - packages=setuptools.find_packages(), - include_package_data=True, - license="MIT", - install_requires=[ - "numpy>=1.18.1", - "matplotlib>=3.2.1", - "opencv-python>=4.2.0.32", - "scikit-learn>=0.22.2.post1", - "webcolors>=1.11.1", - ], - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: POSIX :: Linux", - ], - python_requires=">=3.6", -) diff --git a/tests/conftest.py b/tests/conftest.py index a341e0b..8b0c95e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ from __future__ import unicode_literals import os -from distutils import dir_util +import shutil import pytest @@ -42,6 +42,6 @@ def datadir(tmpdir, request): test_dir, _ = os.path.splitext(filename) if os.path.isdir(test_dir): - dir_util.copy_tree(test_dir, bytes(tmpdir)) + shutil.copytree(test_dir, str(tmpdir), dirs_exist_ok=True) return tmpdir diff --git a/tests/test_functional.py b/tests/test_functional.py index 6de785a..54c4dfb 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -3,7 +3,6 @@ test whether text is written to the image """ -import imghdr import mimetypes from pathlib import Path @@ -24,7 +23,8 @@ def test_argument_is_image(image): """ Ensure that the argument parsed is an image """ - assert type(imghdr.what(Path(image))) is str + mime_type, _ = mimetypes.guess_type(str(image)) + assert mime_type is not None and mime_type.startswith("image/") def test_video_passed_is_valid_video(video): diff --git a/tests/test_unit.py b/tests/test_unit.py index 92595f8..1adcc0d 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -3,11 +3,9 @@ From the developers perspective """ -import mimetypes import os from pathlib import Path -import cv2 import pytest from ..colordetect import ColorDetect, VideoColor, col_share