From 0d52e98937391eb0c13df659a3063a347eebb66c Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Thu, 15 Sep 2022 15:32:26 +0300 Subject: [PATCH 1/2] Moved the metadata into `setup.cfg`. Dropped deprecated `distutils`. Added `pyproject.toml`. --- .github/workflows/testing.yml | 6 ++++-- pyproject.toml | 3 +++ setup.cfg | 22 ++++++++++++++++++++++ setup.py | 35 ----------------------------------- 4 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2958c4b..9aed930 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -54,8 +54,10 @@ jobs: - name: Check typing with mypy if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} run: mypy imagehash tests/*.py --follow-imports=silent --ignore-missing-imports || true - - name: Test install from setup.py - run: pip install . + - name: build wheel + run: python3 -m build -nwx . + - name: Install the built wheel + run: pip install --upgrade ./dist/*.whl - run: coverage run -m pytest . - name: Convert coverage output to lcov for coveralls # coverage-lcov requires python 3.6, so we cannot upload results diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b464d1d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=42.2"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 4123426..b8d2052 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,27 @@ +[metadata] +name = ImageHash +version = 4.3.0 +author = Johannes Buchner +author_email = buchner.johannes@gmx.at +license = BSD-2-Clause +description = Image Hashing library +url = https://github.com/JohannesBuchner/imagehash +long_description = file: README.rst +long_description_content_type = text/x-rst + [bdist_wheel] universal = 1 +[options] +packages = imagehash +install_requires = numpy; scipy; pillow; PyWavelets +scripts = find_similar_images.py +test_suite = tests +tests_require = pytest>=3 + +[options.package_data] +imagehash = py.typed + [flake8] count = True statistics = True @@ -15,3 +36,4 @@ ignore= per-file-ignores= ; False positive with multiline strings https://github.com/PyCQA/pycodestyle/issues/376 find_similar_images.py: E101 + diff --git a/setup.py b/setup.py deleted file mode 100644 index f354304..0000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -try: - from setuptools import setup -except BaseException: - from distutils.core import setup - -long_description = '' -with open('README.rst') as f: - long_description = f.read() - -setup( - name='ImageHash', - version='4.3.0', - author='Johannes Buchner', - author_email='buchner.johannes@gmx.at', - packages=['imagehash'], - package_data={'imagehash': ['py.typed']}, - data_files=[('images', ['tests/data/imagehash.png'])], - scripts=['find_similar_images.py'], - url='https://github.com/JohannesBuchner/imagehash', - license='2-clause BSD License', - description='Image Hashing library', - long_description=long_description, - long_description_content_type='text/x-rst', - install_requires=[ - 'numpy', - 'scipy', # for phash - 'pillow', # or PIL - 'PyWavelets', # for whash - ], - test_suite='tests', - tests_require=['pytest>=3'], -) From 91819510e154a989649535a16777a8066bea8cae Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Thu, 15 Sep 2022 15:44:23 +0300 Subject: [PATCH 2/2] Moved the metadata into `PEP 621`-compliant `pyproject.toml`. Dropped package building with Python 2 and old versions of Python 3 which are unsupported by `setuptools` that has `PEP 621` implemented. --- .github/workflows/testing.yml | 7 ++++++- pyproject.toml | 28 +++++++++++++++++++++++++++- setup.cfg | 25 ------------------------- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9aed930..9ccfef3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -37,6 +37,9 @@ jobs: if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} run: | conda install -c anaconda -c conda-forge --file requirements-linting-old.txt coverage-lcov mypy types-six typed-ast + - name: install build dependencies + if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} + run: pip install --upgrade pip setuptools build - name: Preinstall dependencies (Python 2.7) from anaconda if: ${{ matrix.python-version == '2.7' }} run: | @@ -55,10 +58,12 @@ jobs: if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} run: mypy imagehash tests/*.py --follow-imports=silent --ignore-missing-imports || true - name: build wheel + if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} run: python3 -m build -nwx . - name: Install the built wheel + if: ${{ !((matrix.python-version == '2.7') || (matrix.python-version == '3.5')) }} run: pip install --upgrade ./dist/*.whl - - run: coverage run -m pytest . + - run: coverage run -m pytest ./tests - name: Convert coverage output to lcov for coveralls # coverage-lcov requires python 3.6, so we cannot upload results # from python 2 and 3.5 builds :-( diff --git a/pyproject.toml b/pyproject.toml index b464d1d..d977e09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,29 @@ [build-system] -requires = ["setuptools>=42.2"] +requires = ["setuptools>=61.2"] build-backend = "setuptools.build_meta" + +[project] +name = "ImageHash" +version = "4.3.0" +authors = [{name = "Johannes Buchner", email = "buchner.johannes@gmx.at"}] +license = {text = "BSD-2-Clause"} +description = "Image Hashing library" +readme = "README.rst" +dependencies = ["numpy", "scipy", "pillow", "PyWavelets"] + +[project.urls] +Homepage = "https://github.com/JohannesBuchner/imagehash" + +[project.optional-dependencies] +testing = ["pytest>=3"] + +[tool.setuptools] +packages = ["imagehash"] +script-files = ["find_similar_images.py"] +include-package-data = true + +[tool.setuptools.package-data] +imagehash = ["py.typed"] + +[tool.distutils.bdist_wheel] +universal = 1 diff --git a/setup.cfg b/setup.cfg index b8d2052..45f70e8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,27 +1,3 @@ -[metadata] -name = ImageHash -version = 4.3.0 -author = Johannes Buchner -author_email = buchner.johannes@gmx.at -license = BSD-2-Clause -description = Image Hashing library -url = https://github.com/JohannesBuchner/imagehash -long_description = file: README.rst -long_description_content_type = text/x-rst - -[bdist_wheel] -universal = 1 - -[options] -packages = imagehash -install_requires = numpy; scipy; pillow; PyWavelets -scripts = find_similar_images.py -test_suite = tests -tests_require = pytest>=3 - -[options.package_data] -imagehash = py.typed - [flake8] count = True statistics = True @@ -36,4 +12,3 @@ ignore= per-file-ignores= ; False positive with multiline strings https://github.com/PyCQA/pycodestyle/issues/376 find_similar_images.py: E101 -