Add an __init__.py file so we can add paths to CUDA libs on windows.

pull/2118/head
Davis King 4 years ago
parent 53b6ea3bf5
commit 7fcb6c285d

@ -229,13 +229,14 @@ setup(
author_email='davis@dlib.net',
url='https://github.com/davisking/dlib',
license='Boost Software License',
ext_modules=[CMakeExtension('dlib','tools/python')],
ext_modules=[CMakeExtension('_dlib_pybind11','tools/python')],
cmdclass=dict(build_ext=CMakeBuild, test=PyTest),
zip_safe=False,
# 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'],
package_dir={'': 'tools/python'},
keywords=['dlib', 'Computer Vision', 'Machine Learning'],
classifiers=[
'Development Status :: 5 - Production/Stable',

@ -68,8 +68,6 @@ if(NOT ${DLIB_NO_GUI_SUPPORT})
list(APPEND python_srcs src/gui.cpp)
endif()
pybind11_add_module(dlib_python ${python_srcs})
target_link_libraries(dlib_python PRIVATE dlib::dlib)
# Set the output library name to dlib because that's what setup.py and distutils expects.
set_target_properties(dlib_python PROPERTIES OUTPUT_NAME dlib)
pybind11_add_module(_dlib_pybind11 ${python_srcs})
target_link_libraries(_dlib_pybind11 PRIVATE dlib::dlib)

@ -0,0 +1,11 @@
from _dlib_pybind11 import *
from _dlib_pybind11 import __version__, __time_compiled__
try:
import os
# On windows you must call os.add_dll_directory() to allow linking to external DLLs. See
# https://docs.python.org/3.8/whatsnew/3.8.html#bpo-36085-whatsnew.
os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))
except (AttributeError,KeyError):
pass

@ -37,7 +37,7 @@ void bind_line(py::module& m);
void bind_gui(py::module& m);
#endif
PYBIND11_MODULE(dlib, m)
PYBIND11_MODULE(_dlib_pybind11, m)
{
warn_about_unavailable_but_used_cpu_instructions();

Loading…
Cancel
Save