mirror of
https://github.com/facefusion/facefusion.git
synced 2026-08-09 02:26:04 +02:00
ship libssl and libcrypto in linux (#1095)
This commit is contained in:
@@ -1,47 +1,97 @@
|
||||
import ctypes
|
||||
import os
|
||||
from functools import lru_cache
|
||||
from typing import Dict, Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||
from facefusion.filesystem import resolve_relative_path
|
||||
from facefusion.types import DownloadSet
|
||||
|
||||
|
||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
||||
if is_linux():
|
||||
return 'linux/libdatachannel.hash', 'linux/libdatachannel.so'
|
||||
if is_macos():
|
||||
return 'macos/libdatachannel.hash', 'macos/libdatachannel.dylib'
|
||||
if is_windows():
|
||||
return 'windows/datachannel.hash', 'windows/datachannel.dll'
|
||||
return None
|
||||
from facefusion.types import LibrarySet
|
||||
|
||||
|
||||
@lru_cache
|
||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
||||
library_hash_path, library_source_path = resolve_library_paths()
|
||||
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
def create_static_library_set() -> Optional[LibrarySet]:
|
||||
if is_linux():
|
||||
return\
|
||||
{
|
||||
'datachannel':
|
||||
'hashes':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'datachannel':
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libdatachannel.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libdatachannel.hash')
|
||||
},
|
||||
'crypto':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libcrypto.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libcrypto.hash')
|
||||
},
|
||||
'ssl':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libssl.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libssl.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libdatachannel.so'),
|
||||
'path': resolve_relative_path('../.libraries/libdatachannel.so')
|
||||
},
|
||||
'crypto':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libcrypto.so'),
|
||||
'path': resolve_relative_path('../.libraries/libcrypto.so')
|
||||
},
|
||||
'ssl':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0-a', 'linux/libssl.so'),
|
||||
'path': resolve_relative_path('../.libraries/libssl.so')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if is_macos():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libdatachannel.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libdatachannel.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libdatachannel.dylib'),
|
||||
'path': resolve_relative_path('../.libraries/libdatachannel.dylib')
|
||||
}
|
||||
}
|
||||
}
|
||||
if is_windows():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/datachannel.hash'),
|
||||
'path': resolve_relative_path('../.libraries/datachannel.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'datachannel':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/datachannel.dll'),
|
||||
'path': resolve_relative_path('../.libraries/datachannel.dll')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def pre_check() -> bool:
|
||||
@@ -53,13 +103,19 @@ def pre_check() -> bool:
|
||||
|
||||
@lru_cache
|
||||
def create_static_library() -> Optional[ctypes.CDLL]:
|
||||
library_path = create_static_library_set().get('sources').get('datachannel').get('path')
|
||||
datachannel_source_path = create_static_library_set().get('sources').get('datachannel').get('path')
|
||||
crypto_source_path = create_static_library_set().get('sources').get('crypto').get('path')
|
||||
ssl_source_path = create_static_library_set().get('sources').get('ssl').get('path')
|
||||
|
||||
if datachannel_source_path:
|
||||
if crypto_source_path and ssl_source_path:
|
||||
ctypes.CDLL(crypto_source_path)
|
||||
ctypes.CDLL(ssl_source_path)
|
||||
|
||||
if library_path:
|
||||
if is_windows():
|
||||
library = ctypes.CDLL(library_path, winmode = 0)
|
||||
library = ctypes.CDLL(datachannel_source_path, winmode = 0)
|
||||
else:
|
||||
library = ctypes.CDLL(library_path)
|
||||
library = ctypes.CDLL(datachannel_source_path)
|
||||
|
||||
if library:
|
||||
return init_ctypes(library)
|
||||
|
||||
@@ -1,47 +1,79 @@
|
||||
import ctypes
|
||||
import os
|
||||
from functools import lru_cache
|
||||
from typing import Dict, Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||
from facefusion.filesystem import resolve_relative_path
|
||||
from facefusion.types import DownloadSet
|
||||
|
||||
|
||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
||||
if is_linux():
|
||||
return 'linux/libopus.hash', 'linux/libopus.so'
|
||||
if is_macos():
|
||||
return 'macos/libopus.hash', 'macos/libopus.dylib'
|
||||
if is_windows():
|
||||
return 'windows/opus.hash', 'windows/opus.dll'
|
||||
return None
|
||||
from facefusion.types import LibrarySet
|
||||
|
||||
|
||||
@lru_cache
|
||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
||||
library_hash_path, library_source_path = resolve_library_paths()
|
||||
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
def create_static_library_set() -> Optional[LibrarySet]:
|
||||
if is_linux():
|
||||
return\
|
||||
{
|
||||
'opus':
|
||||
'hashes':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'opus':
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libopus.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libopus.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libopus.so'),
|
||||
'path': resolve_relative_path('../.libraries/libopus.so')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if is_macos():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libopus.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libopus.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libopus.dylib'),
|
||||
'path': resolve_relative_path('../.libraries/libopus.dylib')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if is_windows():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/opus.hash'),
|
||||
'path': resolve_relative_path('../.libraries/opus.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'opus':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/opus.dll'),
|
||||
'path': resolve_relative_path('../.libraries/opus.dll')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def pre_check() -> bool:
|
||||
|
||||
+60
-30
@@ -1,47 +1,77 @@
|
||||
import ctypes
|
||||
import os
|
||||
from functools import lru_cache
|
||||
from typing import Dict, Optional, Tuple
|
||||
from typing import Optional
|
||||
|
||||
from facefusion.common_helper import is_linux, is_macos, is_windows
|
||||
from facefusion.download import conditional_download_hashes, conditional_download_sources, resolve_download_url_by_provider
|
||||
from facefusion.filesystem import resolve_relative_path
|
||||
from facefusion.types import DownloadSet
|
||||
|
||||
|
||||
def resolve_library_paths() -> Optional[Tuple[str, str]]:
|
||||
if is_linux():
|
||||
return 'linux/libvpx.hash', 'linux/libvpx.so'
|
||||
if is_macos():
|
||||
return 'macos/libvpx.hash', 'macos/libvpx.dylib'
|
||||
if is_windows():
|
||||
return 'windows/vpx.hash', 'windows/vpx.dll'
|
||||
return None
|
||||
from facefusion.types import LibrarySet
|
||||
|
||||
|
||||
@lru_cache
|
||||
def create_static_library_set() -> Dict[str, DownloadSet]:
|
||||
library_hash_path, library_source_path = resolve_library_paths()
|
||||
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
def create_static_library_set() -> Optional[LibrarySet]:
|
||||
if is_linux():
|
||||
return\
|
||||
{
|
||||
'vpx':
|
||||
'hashes':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_hash_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_hash_path))
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'vpx':
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libvpx.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libvpx.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', library_source_path),
|
||||
'path': resolve_relative_path('../.libraries/' + os.path.basename(library_source_path))
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'linux/libvpx.so'),
|
||||
'path': resolve_relative_path('../.libraries/libvpx.so')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if is_macos():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libvpx.hash'),
|
||||
'path': resolve_relative_path('../.libraries/libvpx.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'macos/libvpx.dylib'),
|
||||
'path': resolve_relative_path('../.libraries/libvpx.dylib')
|
||||
}
|
||||
}
|
||||
}
|
||||
if is_windows():
|
||||
return\
|
||||
{
|
||||
'hashes':
|
||||
{
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/vpx.hash'),
|
||||
'path': resolve_relative_path('../.libraries/vpx.hash')
|
||||
}
|
||||
},
|
||||
'sources':
|
||||
{
|
||||
'vpx':
|
||||
{
|
||||
'url': resolve_download_url_by_provider('huggingface', 'libraries-4.0.0', 'windows/vpx.dll'),
|
||||
'path': resolve_relative_path('../.libraries/vpx.dll')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def pre_check() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user