資源簡介
使用方法查看:https://blog.csdn.net/songqiu65/article/details/88116549
通過dlib源碼編譯python失敗,通過修改setup.py后,配合cmake和mingw進行編譯dlib并生成python庫。如果你想要其他的替換mingw,請文件搜索change this。
代碼片段和文件信息
“““setup?for?the?dlib?project
?Copyright?(C)?2015??Ehsan?Azar?(dashesy@linux.com)
?License:?Boost?Software?License???See?LICENSE.txt?for?the?full?license.
This?file?basically?just?uses?CMake?to?compile?the?dlib?python?bindings?project
located?in?the?tools/python?folder?and?then?puts?the?outputs?into?standard
python?packages.
To?build?the?dlib:
????python?setup.py?build
To?build?and?install:
????python?setup.py?install
To?package?the?wheel?(after?pip?installing?twine?and?wheel):
????python?setup.py?bdist_wheel
To?upload?the?binary?wheel?to?PyPi
????twine?upload?dist/*.whl
To?upload?the?source?distribution?to?PyPi
????python?setup.py?sdist?
????twine?upload?dist/dlib-*.tar.gz
To?exclude?certain?options?in?the?cmake?config?use?--no:
????for?example:
????--no?USE_AVX_INSTRUCTIONS:?will?set?-DUSE_AVX_INSTRUCTIONS=no
Additional?options:
????--compiler-flags:?pass?flags?onto?the?compiler?e.g.?--compiler-flags?“-Os?-Wall“?passes?-Os?-Wall?onto?GCC.
????-G:?Set?the?CMake?generator.??E.g.?-G?“Visual?Studio?14?2015“
????--clean:?delete?any?previous?build?folders?and?rebuild.??You?should?do?this?if?you?change?any?build?options
?????????????by?setting?--compiler-flags?or?--no?since?the?last?time?you?ran?a?build.??This?will
?????????????ensure?the?changes?take?effect.
????--set:?set?arbitrary?cmake?options?e.g.?--set?CUDA_HOST_COMPILER=/usr/bin/gcc-6.4.0
???????????passes?-DCUDA_HOST_COMPILER=/usr/bin/gcc-6.4.0?to?CMake.
“““
import?os
import?re
import?sys
import?shutil
import?platform
import?subprocess
import?multiprocessing
from?distutils?import?log
from?math?import?ceilfloor
from?setuptools?import?setup?Extension
from?setuptools.command.build_ext?import?build_ext
from?distutils.version?import?LooseVersion
def?get_extra_cmake_options():
????“““read?--clean?--no?--set?--compiler-flags?and?-G?options?from?the?command?line?and?add?them?as?cmake?switches.
????“““
????_cmake_extra_options?=?[]
????_clean_build_folder?=?False
????opt_key?=?None
????argv?=?[arg?for?arg?in?sys.argv]??#?take?a?copy
????#?parse?command?line?options?and?consume?those?we?care?about
????for?arg?in?argv:
????????if?opt_key?==?‘compiler-flags‘:
????????????_cmake_extra_options.append(‘-DCMAKE_CXX_FLAGS={arg}‘.format(arg=arg.strip()))
????????elif?opt_key?==?‘G‘:
????????????_cmake_extra_options?+=?[]
????????elif?opt_key?==?‘no‘:
????????????_cmake_extra_options.append(‘-D{arg}=no‘.format(arg=arg.strip()))
????????elif?opt_key?==?‘set‘:
????????????_cmake_extra_options.append(‘-D{arg}‘.format(arg=arg.strip()))
????????if?opt_key:
????????????sys.argv.remove(arg)
????????????opt_key?=?None
????????????continue
????????if?arg?==?‘--clean‘:
????????????_clean_build_folder?=?True
????????????sys.argv.remove(arg)
????????????continue
????????if?arg?==?‘--yes‘:
????????????print(“The?--yes?options?to?dlib‘s?setup.py?don‘t?do?anything?since?all?these?options?“)
????????????print(“are?on?by?default.??So?--yes?has?been?removed.??Do?not?give?it?to?setup.py.“)
????????????sys.exit(1)
- 上一篇:樹莓派動作捕捉抓拍存儲圖像腳本
- 下一篇:決策樹分類算法
評論
共有 條評論