Skip to content

Commit 4cf8f57

Browse files
authored
update python packaging to work with newer toolchains (davisking#3102)
1 parent 561759c commit 4cf8f57

File tree

4 files changed

+17
-28
lines changed

4 files changed

+17
-28
lines changed

README.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,17 @@ vcpkg install dlib
3737

3838
## Compiling dlib Python API
3939

40-
Before you can run the Python example programs you must install the build requirement.
40+
Either fetch the latest stable release of dlib from PyPi and install that:
4141
```bash
42-
python -m venv venv
43-
pip install build
42+
pip install dlib
4443
```
45-
46-
Then you must compile dlib and install it in your environment. Type:
44+
Or fetch the very latest version from github and install that:
4745
```bash
48-
python -m build --wheel
49-
pip install dist/dlib-<version>.whl
46+
git clone https://github.com/davisking/dlib.git
47+
cd dlib
48+
pip install .
5049
```
5150

52-
Or download dlib using PyPi:
53-
```bash
54-
pip install dlib
55-
```
5651

5752
## Running the unit test suite
5853

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
2+
requires = ["setuptools", "wheel", "packaging"]
33
build-backend = "setuptools.build_meta"
4+

setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,21 @@
2828
import os
2929
import re
3030
import sys
31+
import errno
32+
import stat
3133
import shutil
3234
import platform
3335
import subprocess
3436
import multiprocessing
35-
from distutils import log
36-
from math import ceil,floor
37+
from math import floor
3738

39+
from packaging.version import Version, parse as parse_version
3840
from setuptools import find_packages, setup, Extension
3941
from setuptools.command.build_ext import build_ext
40-
from distutils.version import LooseVersion
42+
import logging
4143

44+
logging.basicConfig(level=logging.INFO)
45+
log = logging.getLogger("setup")
4246

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

9195
class CMakeExtension(Extension):
9296
def __init__(self, name, sourcedir=''):
93-
Extension.__init__(self, name, sources=[])
97+
super().__init__(name, sources=[])
9498
self.sourcedir = os.path.abspath(sourcedir)
9599

96100
def rmtree(name):
@@ -160,7 +164,7 @@ def get_cmake_version(self):
160164
def run(self):
161165
cmake_version = self.get_cmake_version()
162166
if platform.system() == "Windows":
163-
if LooseVersion(cmake_version) < '3.1.0':
167+
if parse_version(cmake_version) < Version('3.1.0'):
164168
sys.stderr.write("\nERROR: CMake >= 3.1.0 is required on Windows\n\n")
165169
sys.exit(1)
166170

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

239-
def read_entire_file(fname):
240-
"""Read text out of a file relative to setup.py. """
241-
return open(os.path.join(fname)).read()
242-
243243
setup(
244244
name='dlib',
245245
version=read_version_from_cmakelists('dlib/CMakeLists.txt'),

tools/python/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ if (POLICY CMP0042)
2727
endif()
2828

2929

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

3831
add_subdirectory(../../dlib/external/pybind11 pybind11_build)
3932
add_subdirectory(../../dlib dlib_build)

0 commit comments

Comments
 (0)