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

This commit is contained in:
Davis King 2020-06-07 16:42:44 -04:00
parent 53b6ea3bf5
commit 7fcb6c285d
4 changed files with 16 additions and 6 deletions

View File

@ -229,13 +229,14 @@ setup(
author_email='davis@dlib.net', author_email='davis@dlib.net',
url='https://github.com/davisking/dlib', url='https://github.com/davisking/dlib',
license='Boost Software License', license='Boost Software License',
ext_modules=[CMakeExtension('dlib','tools/python')], ext_modules=[CMakeExtension('_dlib_pybind11','tools/python')],
cmdclass=dict(build_ext=CMakeBuild, test=PyTest), cmdclass=dict(build_ext=CMakeBuild, test=PyTest),
zip_safe=False, zip_safe=False,
# We need an older more-itertools version because v6 broke pytest (for everyone, not just dlib) # 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'], 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. #install_requires=['cmake'], # removed because the pip cmake package is busted, maybe someday it will be usable.
packages=['dlib'], packages=['dlib'],
package_dir={'': 'tools/python'},
keywords=['dlib', 'Computer Vision', 'Machine Learning'], keywords=['dlib', 'Computer Vision', 'Machine Learning'],
classifiers=[ classifiers=[
'Development Status :: 5 - Production/Stable', 'Development Status :: 5 - Production/Stable',

View File

@ -68,8 +68,6 @@ if(NOT ${DLIB_NO_GUI_SUPPORT})
list(APPEND python_srcs src/gui.cpp) list(APPEND python_srcs src/gui.cpp)
endif() endif()
pybind11_add_module(dlib_python ${python_srcs}) pybind11_add_module(_dlib_pybind11 ${python_srcs})
target_link_libraries(dlib_python PRIVATE dlib::dlib) target_link_libraries(_dlib_pybind11 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)

View File

@ -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

View File

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