Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,17 @@ vcpkg install dlib

## Compiling dlib Python API

Before you can run the Python example programs you must install the build requirement.
Either fetch the latest stable release of dlib from PyPi and install that:
```bash
python -m venv venv
pip install build
pip install dlib
```

Then you must compile dlib and install it in your environment. Type:
Or fetch the very latest version from github and install that:
```bash
python -m build --wheel
pip install dist/dlib-<version>.whl
git clone https://github.com/davisking/dlib.git
cd dlib
pip install .
```

Or download dlib using PyPi:
```bash
pip install dlib
```

## Running the unit test suite

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

18 changes: 9 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@
import os
import re
import sys
import errno
import stat
import shutil
import platform
import subprocess
import multiprocessing
from distutils import log
from math import ceil,floor
from math import floor

from packaging.version import Version, parse as parse_version
from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

distutils is no more in the latest python version

import logging

logging.basicConfig(level=logging.INFO)
log = logging.getLogger("setup")

def get_extra_cmake_options():
"""read --clean, --no, --set, --compiler-flags, and -G options from the command line and add them as cmake switches.
Expand Down Expand Up @@ -90,7 +94,7 @@ def get_extra_cmake_options():

class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
super().__init__(name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)

def rmtree(name):
Expand Down Expand Up @@ -160,7 +164,7 @@ def get_cmake_version(self):
def run(self):
cmake_version = self.get_cmake_version()
if platform.system() == "Windows":
if LooseVersion(cmake_version) < '3.1.0':
if parse_version(cmake_version) < Version('3.1.0'):
sys.stderr.write("\nERROR: CMake >= 3.1.0 is required on Windows\n\n")
sys.exit(1)

Expand Down Expand Up @@ -236,10 +240,6 @@ def read_version_from_cmakelists(cmake_file):
patch = re.findall("set\\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0]
return major + '.' + minor + '.' + patch

def read_entire_file(fname):
"""Read text out of a file relative to setup.py. """
return open(os.path.join(fname)).read()

setup(
name='dlib',
version=read_version_from_cmakelists('dlib/CMakeLists.txt'),
Expand Down
7 changes: 0 additions & 7 deletions tools/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ if (POLICY CMP0042)
endif()


# To avoid dll hell, always link everything statically when compiling in
# visual studio. This way, the resulting library won't depend on a bunch
# of other dll files and can be safely copied to someone else's computer
# and expected to run.
if (MSVC)
include(${CMAKE_CURRENT_LIST_DIR}/../../dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake)
endif()
Comment on lines -34 to -36

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes building fail in the very latest version of visual studio and the python interpreter in windows now.


add_subdirectory(../../dlib/external/pybind11 pybind11_build)
add_subdirectory(../../dlib dlib_build)
Expand Down
Loading