From bebba4ca9856a1ea9938cf3ecdad822df07f8ada Mon Sep 17 00:00:00 2001 From: Rover van der Noort <33723189+rvandernoort@users.noreply.github.com> Date: Sat, 3 Jun 2023 22:12:44 +0200 Subject: [PATCH] Add minimal pyproject.toml (#2804) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add minimal pyproject.toml * Update README for Python compile and install * Remove duplicate meta * Fix pixel saturation in interpolate_quadratic (#2806) * Fix pixel saturation in interpolate_quadratic * Use pixel_type_t alias * cleanup --------- Co-authored-by: AdriĆ  Arrufat <1671644+arrufat@users.noreply.github.com> Co-authored-by: Davis King --- .gitignore | 1 + README.md | 14 ++++++++++++-- pyproject.toml | 3 +++ setup.py | 17 +++-------------- 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 5ad181a5e..f57cab57f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ docs/docs/python/classes.txt docs/docs/python/functions.txt docs/docs/python/constants.txt **/.vscode +**/venv diff --git a/README.md b/README.md index da1ec8700..79cc041d2 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,22 @@ vcpkg install dlib ## Compiling dlib Python API -Before you can run the Python example programs you must compile dlib. Type: +Before you can run the Python example programs you must install the build requirement. +```bash +python -m venv venv +pip install build +``` +Then you must compile dlib and install it in your environment. Type: ```bash -python setup.py install +python -m build --wheel +pip install dist/dlib-.whl ``` +Or download dlib using PyPi: +```bash +pip install dlib +``` ## Running the unit test suite diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..2fd725a0d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "cmake"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index 8e4330986..c32c210e2 100644 --- a/setup.py +++ b/setup.py @@ -6,14 +6,10 @@ This file basically just uses CMake to compile the dlib python bindings project located in the tools/python folder and then puts the outputs into standard python packages. -To build the dlib: +To build dlib: python setup.py build To build and install: python setup.py install -To package the wheel (after pip installing twine and wheel): - python setup.py bdist_wheel -To upload the binary wheel to PyPi - twine upload dist/*.whl To upload the source distribution to PyPi python setup.py sdist twine upload dist/dlib-*.tar.gz @@ -39,7 +35,7 @@ import multiprocessing from distutils import log from math import ceil,floor -from setuptools import setup, Extension +from setuptools import find_packages, setup, Extension from setuptools.command.build_ext import build_ext from distutils.version import LooseVersion @@ -234,7 +230,7 @@ setup( # We need an older more-itertools version because v6 broke pytest (for everyone, not just dlib) tests_require=['pytest==3.8', 'more-itertools<6.0.0'], #install_requires=['cmake'], # removed because the pip cmake package is busted, maybe someday it will be usable. - packages=['dlib'], + packages=find_packages(exclude=['python_examples']), package_dir={'': 'tools/python'}, keywords=['dlib', 'Computer Vision', 'Machine Learning'], classifiers=[ @@ -248,13 +244,6 @@ setup( 'Operating System :: Microsoft :: Windows', 'Programming Language :: C++', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Artificial Intelligence', 'Topic :: Scientific/Engineering :: Image Recognition',