davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.43k stars 3.37k forks source link

cant install #2652

Closed TAMILVIP007 closed 2 years ago

TAMILVIP007 commented 2 years ago

running install C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools. warnings.warn( running bdist_egg running egg_info creating tools\python\dlib.egg-info writing tools/python\dlib.egg-info\PKG-INFO writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt writing top-level names to tools/python\dlib.egg-info\top_level.txt writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build' no previously-included directories found matching 'dlib\cmake_utils*\build' warning: no previously-included files matching '*.pyc' found anywhere in distribution adding license file 'LICENSE' adding license file 'LICENSE.txt' writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py running build_ext C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. if LooseVersion(cmake_version) < '3.1.0': Building extension for Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] Invoking CMake setup: 'cmake C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310 -DPYTHON_EXECUTABLE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310 -A x64' CMake Error at CMakeLists.txt:5 (message):

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You must use Visual Studio to build a python extension on windows. If you are getting this error it means you have not installed Visual C++. Note that there are many flavors of Visual Studio, like Visual Studio for C# development. You need to install Visual Studio for C++.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

-- Configuring incomplete, errors occurred! See also "C:/Users/indrajeeth/AppData/Local/Programs/Python/Python310/Lib/site-packages/build/temp.win-amd64-cpython-310/Release/CMakeFiles/CMakeOutput.log". Traceback (most recent call last): File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 222, in setup( File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools__init__.py", line 87, in setup return distutils.core.setup(**attrs) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\core.py", line 185, in setup
return run_commands(dist) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\core.py", line 201, in run_commands dist.run_commands() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 973, in run_commands self.run_command(cmd) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install.py", line 74, in run
self.do_egg_install() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install.py", line 123, in do_egg_install self.run_command('bdist_egg') File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\bdist_egg.py", line 165, in run cmd = self.call_command('install_lib', warn_dir=0) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\bdist_egg.py", line 151, in call_command self.run_command(cmdname) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\command\install_lib.py", line 11, in run
self.build() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\command\install_lib.py", line 112, in build self.run_command('build_ext') File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\cmd.py", line 319, in run_command self.distribution.run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setuptools_distutils\dist.py", line 992, in run_command cmd_obj.run() File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 134, in run self.build_extension(ext) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\setup.py", line 171, in build_extension subprocess.check_call(cmake_setup, cwd=build_folder) File "C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\tools\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310', '-DPYTHON_EXECUTABLE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\indrajeeth\AppData\Local\Programs\Python\Python310\Lib\site-packages\build\lib.win-amd64-cpython-310', '-A', 'x64']' returned non-zero exit status 1.

i tried to install it in my windows but givin this error os - windowns 10 py version 3.10 vs studio code is installed but still gettin this error

TanimSk commented 2 years ago

Do you have Cmake installed? https://cmake.org/download/ make sure to add it into PATH

TAMILVIP007 commented 2 years ago

Do you have Cmake installed? https://cmake.org/download/ make sure to add it into PATH

Yeh it is

goyalyashpal commented 1 year ago

hey Indrajeeth @TAMILVIP007 how did u fix this?? i (and my teammates too) are facing exactly same issue (https://github.com/davisking/dlib/issues/2801)

goyalyashpal commented 1 year ago

Environment info:

Logs

$ pip install dlib --verbose
Logs ```powershell $ pip install dlib --verbose Using pip 23.1.2 from D:\15_devt\GitHub\oooo\.venv\Lib\site-packages\pip (python 3.11) Collecting dlib Using cached dlib-19.24.2.tar.gz (11.8 MB) Running command pip subprocess to install build dependencies Collecting setuptools Using cached setuptools-68.0.0-py3-none-any.whl (804 kB) Collecting wheel Using cached wheel-0.40.0-py3-none-any.whl (64 kB) Collecting cmake Using cached cmake-3.26.4-py2.py3-none-win_amd64.whl (33.0 MB) Installing collected packages: cmake, wheel, setuptools Successfully installed cmake-3.26.4 setuptools-68.0.0 wheel-0.40.0 Installing build dependencies ... done Running command Getting requirements to build wheel running egg_info writing tools/python\dlib.egg-info\PKG-INFO writing dependency_links to tools/python\dlib.egg-info\dependency_links.txt writing top-level names to tools/python\dlib.egg-info\top_level.txt reading manifest file 'tools/python\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build*' no previously-included directories found matching 'dlib\cmake_utils\*\build*' no previously-included directories found matching 'dlib\test' warning: no previously-included files matching '*.pyc' found anywhere in distribution adding license file 'LICENSE.txt' writing manifest file 'tools/python\dlib.egg-info\SOURCES.txt' Getting requirements to build wheel ... done Running command Preparing metadata (pyproject.toml) running dist_info creating %LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info writing %LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\PKG-INFO writing dependency_links to %LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\dependency_links.txt writing top-level names to %LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\top_level.txt writing manifest file '%LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\SOURCES.txt' reading manifest file '%LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' no previously-included directories found matching 'tools\python\build*' no previously-included directories found matching 'dlib\cmake_utils\*\build*' no previously-included directories found matching 'dlib\test' warning: no previously-included files matching '*.pyc' found anywhere in distribution adding license file 'LICENSE.txt' writing manifest file '%LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib.egg-info\SOURCES.txt' creating '%LOCALAPPDATA%\Temp\pip-modern-metadata-g7st43en\dlib-19.24.2.dist-info' Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: dlib Running command Building wheel for dlib (pyproject.toml) running bdist_wheel running build running build_ext :125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. Building extension for Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] Invoking CMake setup: 'cmake %LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=D:\15_devt\GitHub\oooo\.venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311 -A x64' -- Building for: NMake Makefiles CMake Error at CMakeLists.txt:5 (message): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! You must use Visual Studio to build a python extension on windows. If you are getting this error it means you have not installed Visual C++. Note that there are many flavors of Visual Studio, like Visual Studio for C# development. You need to install Visual Studio for C++. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- Configuring incomplete, errors occurred! Traceback (most recent call last): File "D:\15_devt\GitHub\oooo\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in main() File "D:\15_devt\GitHub\oooo\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\15_devt\GitHub\oooo\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\build_meta.py", line 416, in build_wheel return self._build_with_temp_dir(['bdist_wheel'], '.whl', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\build_meta.py", line 401, in _build_with_temp_dir self.run_setup() File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup exec(code, locals()) File "", line 218, in File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\__init__.py", line 107, in setup return distutils.core.setup(**attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup return run_commands(dist) ^^^^^^^^^^^^^^^^^^ File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands dist.run_commands() File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands self.run_command(cmd) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command super().run_command(command) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 343, in run self.run_command("build") File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command super().run_command(command) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run self.run_command(cmd_name) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command self.distribution.run_command(command) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command super().run_command(command) File "%LOCALAPPDATA%\Temp\pip-build-env-uaev03an\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command cmd_obj.run() File "", line 130, in run File "", line 167, in build_extension File "D:\ProgramFiles\Python\Python311\Lib\subprocess.py", line 413, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\NemoUSR\\AppData\\Local\\Temp\\pip-install-m4l_t_ho\\dlib_3eca10703e464ad1a0cbb41bdcc2b738\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\NemoUSR\\AppData\\Local\\Temp\\pip-install-m4l_t_ho\\dlib_3eca10703e464ad1a0cbb41bdcc2b738\\build\\lib.win-amd64-cpython-311', '-DPYTHON_EXECUTABLE=D:\\15_devt\\GitHub\\oooo\\.venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\NemoUSR\\AppData\\Local\\Temp\\pip-install-m4l_t_ho\\dlib_3eca10703e464ad1a0cbb41bdcc2b738\\build\\lib.win-amd64-cpython-311', '-A', 'x64']' returned non-zero exit status 1. error: subprocess-exited-with-error × Building wheel for dlib (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: 'D:\15_devt\GitHub\oooo\.venv\Scripts\python.exe' 'D:\15_devt\GitHub\oooo\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py' build_wheel 'C:\Users\NEMOUS~1\AppData\Local\Temp\tmp1mc7baho' cwd: %LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738 Building wheel for dlib (pyproject.toml) ... error ERROR: Failed building wheel for dlib Failed to build dlib ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects ```

cmake invocation breakdown

cmake %LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\tools\python 
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311 
-DPYTHON_EXECUTABLE=D:\15_devt\GitHub\oooo\.venv\Scripts\python.exe 
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=%LOCALAPPDATA%\Temp\pip-install-m4l_t_ho\dlib_3eca10703e464ad1a0cbb41bdcc2b738\build\lib.win-amd64-cpython-311 
-A x64
facug91 commented 1 year ago

Do you have Visual C++ installed?

goyalyashpal commented 1 year ago

Do you have Visual C++ installed?

nope... but that shouldn't be required either; per the official documentation:

Note that you need to have CMake and a working C++ compiler installed for this to work. - Using dlib from Python http://dlib.net/compile.html

or am i missing something?

facug91 commented 1 year ago

Well, what you say about the documentation seems right, it doesn't specify Visual C++ for Windows. But in the error log you uploaded says:

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    You must use Visual Studio to build a python extension on windows.  If you
    are getting this error it means you have not installed Visual C++.  Note
    that there are many flavors of Visual Studio, like Visual Studio for C#
    development.  You need to install Visual Studio for C++.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

So I guess you need to install that one.

facug91 commented 1 year ago

Just to be clear, I hardly ever use Windows, and I've never used dlib with Python, I'm just trying to help. If that doesn't work, maybe someone else can give you a hand.

goyalyashpal commented 1 year ago

self hiding as offtopic


Also, same error is shown on trying to python -m build --wheel

https://github.com/davisking/dlib/blob/3f9c5c1cfdd9c861be1e36ecc166f81b90656205/README.md#L48

goyalyashpal commented 1 year ago

hey @davisking

I am sorry to ask like this, but can u please help look into this.

i have tried looking

but nothing seem to be working and is failing one way or the another... please help 🙏🙏

davisking commented 1 year ago

Well, what you say about the documentation seems right, it doesn't specify Visual C++ for Windows. But in the error log you uploaded says:


    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    You must use Visual Studio to build a python extension on windows.  If you

    are getting this error it means you have not installed Visual C++.  Note

    that there are many flavors of Visual Studio, like Visual Studio for C#

    development.  You need to install Visual Studio for C++.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

So I guess you need to install that one.

This is the answer. You have to do like these instructions say. That is, for windows, python (not dlib) requires visual studio to build python extensions.

goyalyashpal commented 1 year ago

for windows, python (not dlib) requires visual studio ... - @ davisking at https://github.com/davisking/dlib/issues/2652#issuecomment-1639165720

thanks a lot for clearing that up.

  1. so there's no way to use the msys toolchain while installing from python?

  2. if no, then i would prefer compiling dlib separately and use it in python somehow ... if thats possible

i had looked through the dlib.net but in context of buiding with cmake, it only mentions "compile examples" and never how to compile the library to wheel itself.

Edit: now that i mention this, i recall i saw a tutorial compiling to .o object file via toolchain of choice and from there to .whl wheel via pip.... I wii try that.

  1. Would u like to know updates on this approach and see how it went?

  2. I also wondor how do other python libs written in C/++ like numpy etc compile then? I didnt face any issues installing those via pip.


Updates

  1. Q: no way to use msys ...? A: seems no! msys2/python » "the official CPython implementation doesn't support building with GCC/Clang on Windows ..."

  2. Q: tutorial for compiling to .o, then to .whl ... A: can't find that now

^

  1. Q: other python libs like numpy ... A: they distribute .whl wheels. see: "project" ↦ "simple" in the pypi links for the project i.e. in https://pypi.org/project/<lib_name>. On the page that follows, the string after libName-libVer- represents the python distribution that wheel is intended for. So, cp36 means cpython-3.6 and so on.

Aside: Following reminded me that some of these pac-mans mentioned that they fetch packages from community distributed builds... so, maybe going the conda / mamba / micromamba route can save me... 'will see.

Try conda install -c menpo dlib - @rendicahya at https://github.com/davisking/dlib/issues/218#issuecomment-279689660

Thanks a lot, it worked for me too. - @sonineha2191 at https://github.com/davisking/dlib/issues/218#issuecomment-557051243

have you tried this? conda install -c conda-forge dlib=19.4 - @anoumaru at https://github.com/davisking/dlib/issues/218#issuecomment-414132506 - @sonineha2191 at https://github.com/davisking/dlib/issues/218#issuecomment-570043654

it solved my problem - @MengHao666 at https://github.com/davisking/dlib/issues/218#issuecomment-1084496270

goyalyashpal commented 1 year ago

these pac-mans mentioned that they fetch packages from community distributed builds

yeah, used micromamba with packages from the "channel" conda-forge, it fetched this thing for dlib, and finallyyyy it's working good :)

also, the version in conda-forge (at least for dlib) matches the one distributed at pypi (i.e. via pip): 19.24.2 :)

  Name                       Version             Build               Channel
----------------------------------------------------------------------------------
  dlib                       19.24.2             py311he12e1e2_0     conda-forge
davisking commented 1 year ago

Visual studio is free. So you could download it and install in short order. For more details see https://docs.python.org/3/extending/windows.html. The notable detail is it also instructs you to use visual studio. If you want to do something else then you are on your own. I honestly don't know if it would be possible. I expect it would not work though.

goyalyashpal commented 1 year ago

If you want to do something else then you are on your own.

I honestly don't know if it would be possible. I expect it would not work though.

I dont understand what this meant. but i guess u are referring to using other package managers, and its possibility of failing.

accordingly: the conda (or micromamba in my case, hereafter referred as mmb) approach is used by Anaconda IDE, and is widely used as much commonly as pip. also, after completing the setup with mmb, i ran my python program using dlib and it worked.


Visual studio is free. So you could download it and install in short order.

following may sound like a rant, but its not. I am just calmly laying down all the reasons why i didnt follow that way.

  1. Visual Studio might be free (from a direct upfront monetary cost only), but its a ginormous bloat package, which as per this readme by charlielito file (mentioned at #218 comment) consumes 12GB just for download.

  2. Also, like all MicroSoft products (see here for one example) , it doesn't mention upfront the download & install size required. And i assume it wont tell even while downloading either.

    • The file downloaded from the site of Visual Studio "VisualStudioSetup.exe" is just 3-4 MiB, i.e. it will fetch the installer later on and is not standalone.
    • The experience with non-standalone "setups" (hereafter file fetchers) like google chrome, ms vscode, ms widows update helper, google android studio, oracle desktop analytics etc
    • ... tells me this approach is extemely fragile and unreliable as these small fetchers likely dont contain a dedicated robust download manager to resume downloads.
    • Yes, the network connection doesnt always stay silk smooth.
  3. These all things make me feel even more helpless, and like a puppet. Alongwith; it also has an unproductive financial, mental & huge time toll:

    • just waiting hours for download to finish;
    • incurring additional charges on data connection;
    • staying awake at night (in hopes of faster download speeds)
    • yet still having the fears that the whole download can fail even at last moment.
  4. Even after finishing the download:

    • I am forever afraid to uninstall that fat bloat lest having to go through all that again. So, it behaves like a lock-in as well.
    • Oh, and updates....
  5. All this is just not worth it for me. I strive to avoid such trapes at all upfront costs.

the fact that MS distributes the only directly available & "recommended for their OS by tonnes of other softwares" compiler - only as bundled with their IDE is already telling - forced funnel marketing pretty much.


Contrast this with other way, u just spend time actually learning the stuff once, and it most likely remains reproducible in future. no repeated and constant tortures (for lack of a better word at hand).

the download size is communicated beforehand, i am not treated like an illiterate and spoonfed blindly with bloat.

davisking commented 1 year ago

Yeah I feel you. I loath needing to turn on visual studio or deal with it. This stuff is outside my control though. Like what you did was just find some other package system where someone else built dlib with visual studio for you. I really don't want to get into the binary package game, especially on windows, in part because of the issues you mentioned with visual studio. But that is just the tip of the iceberg.

The other problem you will find with these binary dlib packages is they are built to lowest common denominator hardware. So it will be slower than if you built it yourself. E.g. it probably isn't built to use AVX instructions. And I wager it isn't built with CUDA or cuDNN either. And I definitely do not want to get into the repackaging nvidia binaries, that's even more frustrating than dealing with visual studio.

arrufat commented 1 year ago

Actually, I've been thinking about how to solve this problem, too, since a big chunk of the issues that people open here are related to Windows installation and MSVC.

For some time now, I've been keeping an eye on Zig.

I got interested in it for several reasons, but one of them is that it ships with Clang, so it's able to build C++ code.

You just download the binary for your platform from their website and type zig c++ and you get access to a ready to roll C++ compiler (it's just Clang).

So maybe then, just running CC="zig cc" CXX="zig c++" cmake -B build should work. I need to try it, though.

Furthermore, if I made a build.zig that compiles dlib, then the compilation would be trivial on all platforms: just run zig build and done. You could even cross-compile easily, just by passing the target OS as a flag to the command line.

I don't know how hard it is to get CMake feature parity, but I am certainly willing to try. That should probably not be the recommended way of installing dlib if you want to use it as a library, though.

However, being able to build the python module using zig build would be a game changer for Python users, especially those on Windows.

Here's an example of a C project that uses the Zig build system: raylib

EDIT: another example, the creator of Zig also ported FFmpeg to the Zig build system: https://github.com/andrewrk/ffmpeg

davisking commented 1 year ago

That would be neat. It's got to be able to produce dll files that can be loaded by a binary built by visual studio (i.e. the python interpreter). That's the real rub. Visual studio is sort of its own world when it comes to how that all works, which is a big part of the problem.

goyalyashpal commented 1 year ago

one long term possible solution for all this - can be to go to https://discuss.python.org/ and raise your voices and concern about supporting msys2-clang-toolchain as an alternate to MS-VS.

Many other people have done already, if more and more module maintainers raise this concern, then they surely will provide this.

davisking commented 1 year ago

The biggest part of the problem isn't anything the core python devs did or have control over either though. It's really due to the huge variability in C and C++ build systems, linking conventions, and so forth. It's not super clear to me there is much they can do either.

arrufat commented 1 year ago

Yes, I was exposed to the linking conventions issue in here: https://github.com/davisking/dlib/discussions/2838 for the first time in my life.

I had always built everything with the same compiler, so far.

davisking commented 1 year ago

Yeah I'll be real surprised if that works :)

Maybe though. At some point something hopefully unseats visual studio. I kinda want clang to eat the world.

arrufat commented 1 year ago

Oh, why is that? Ease of cross-platform development?

davisking commented 1 year ago

The biggest problem with C++ is how confusing the build process is to people. It's too easy to run into binary incompatibility or ODR problems.

But you could imagine some day there is some standard way to build. And then there can be some decent C++ package management.

Not going to hold my breath though. At its root this requires a bunch of organizations to all cohesively cooperate in a way you don't often see. And there is all this old stuff that needs to be incorporated somehow too. Like Fortran libraries.

arrufat commented 1 year ago

Oh, yeah, that too…

goyalyashpal commented 1 year ago

hi again. can u share the dlib wheeels (i.e. .whl files) for windows with me - even if unofficially? 😓 i am having trouble getting other tools to work with micromamba: https://github.com/mamba-org/mamba/issues/2702


Aside:

microsoft so badly wanted me to leave windows. i will obey them soon - as i will never move to win 11 anyway. following happened when installing flutter sdk

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
arrufat commented 1 year ago

I don't have any dlib wheels.