|
28 | 28 | import os |
29 | 29 | import re |
30 | 30 | import sys |
| 31 | +import errno |
| 32 | +import stat |
31 | 33 | import shutil |
32 | 34 | import platform |
33 | 35 | import subprocess |
34 | 36 | import multiprocessing |
35 | | -from distutils import log |
36 | | -from math import ceil,floor |
| 37 | +from math import floor |
37 | 38 |
|
| 39 | +from packaging.version import Version, parse as parse_version |
38 | 40 | from setuptools import find_packages, setup, Extension |
39 | 41 | from setuptools.command.build_ext import build_ext |
40 | | -from distutils.version import LooseVersion |
| 42 | +import logging |
41 | 43 |
|
| 44 | +logging.basicConfig(level=logging.INFO) |
| 45 | +log = logging.getLogger("setup") |
42 | 46 |
|
43 | 47 | def get_extra_cmake_options(): |
44 | 48 | """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(): |
90 | 94 |
|
91 | 95 | class CMakeExtension(Extension): |
92 | 96 | def __init__(self, name, sourcedir=''): |
93 | | - Extension.__init__(self, name, sources=[]) |
| 97 | + super().__init__(name, sources=[]) |
94 | 98 | self.sourcedir = os.path.abspath(sourcedir) |
95 | 99 |
|
96 | 100 | def rmtree(name): |
@@ -160,7 +164,7 @@ def get_cmake_version(self): |
160 | 164 | def run(self): |
161 | 165 | cmake_version = self.get_cmake_version() |
162 | 166 | if platform.system() == "Windows": |
163 | | - if LooseVersion(cmake_version) < '3.1.0': |
| 167 | + if parse_version(cmake_version) < Version('3.1.0'): |
164 | 168 | sys.stderr.write("\nERROR: CMake >= 3.1.0 is required on Windows\n\n") |
165 | 169 | sys.exit(1) |
166 | 170 |
|
@@ -236,10 +240,6 @@ def read_version_from_cmakelists(cmake_file): |
236 | 240 | patch = re.findall("set\\(CPACK_PACKAGE_VERSION_PATCH.*\"(.*)\"", open(cmake_file).read())[0] |
237 | 241 | return major + '.' + minor + '.' + patch |
238 | 242 |
|
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 | | - |
243 | 243 | setup( |
244 | 244 | name='dlib', |
245 | 245 | version=read_version_from_cmakelists('dlib/CMakeLists.txt'), |
|
0 commit comments