added linux, macos and windows support with pre build binaries

pull/39/head
Ciro 2022-11-05 08:50:12 -03:00
commit 8ed814ee4e
16 zmienionych plików z 148 dodań i 168 usunięć

2
.gitignore vendored
Wyświetl plik

@ -2,6 +2,4 @@ __pycache__
/src/socketify.egg-info
/build
/dist
/src/socketify/*.so
*.so
*.o

Wyświetl plik

@ -19,9 +19,9 @@ app.run()
### pip install
```bash
pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext
pip install git+https://github.com/cirospaciari/socketify.py.git
#or specify PyPy3
pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext
pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git
#or in editable mode
pypy3 -m pip install -e git+https://github.com/cirospaciari/socketify.py.git@main#egg=socketify
```
@ -30,7 +30,7 @@ pypy3 -m pip install -e git+https://github.com/cirospaciari/socketify.py.git@mai
requirements.txt file content
```text
git+https://github.com/cirospaciari/socketify.py.git@main#socketify --global-option="build_ext"
git+https://github.com/cirospaciari/socketify.py.git@main#socketify
```
install command
@ -57,7 +57,7 @@ git clone https://github.com/cirospaciari/socketify.py.git
cd ./socketify.py
git submodule update --init --recursive --remote
#install local pip
pypy3 -m pip install . --global-option=build_ext #--no-cache-dir is an option
pypy3 -m pip install .
#install in editable mode
pypy3 -m pip install -e .
#if you want to remove

Wyświetl plik

@ -4,53 +4,53 @@ vi = sys.version_info
if vi < (3, 7):
raise RuntimeError('socketify requires Python 3.7 or greater')
if sys.platform in ('win32', 'cygwin', 'cli'):
raise RuntimeError('socketify does not support Windows at the moment')
# if sys.platform in ('win32', 'cygwin', 'cli'):
# raise RuntimeError('socketify does not support Windows at the moment')
import setuptools
from setuptools.command.sdist import sdist
from setuptools.command.build_ext import build_ext
# from setuptools.command.sdist import sdist
# from setuptools.command.build_ext import build_ext
import pathlib
import os
import shutil
import subprocess
# import pathlib
# import os
# import shutil
# import subprocess
_ROOT = pathlib.Path(__file__).parent
# _ROOT = pathlib.Path(__file__).parent
UWS_DIR = str(_ROOT / "src" / "socketify" /"uWebSockets")
UWS_BUILD_DIR = str(_ROOT / "build" /"uWebSockets")
# UWS_DIR = str(_ROOT / "src" / "socketify" /"uWebSockets")
# UWS_BUILD_DIR = str(_ROOT / "build" /"uWebSockets")
NATIVE_CAPI_DIR = str(_ROOT / "build" / "native")
NATIVE_LIB_PATH = str(_ROOT / "build" / "libsocketify.so")
NATIVE_DIR = str(_ROOT / "src" / "socketify" /"native")
NATIVE_BUILD_DIR = str(_ROOT / "build" /"native")
NATIVE_LIB_OUTPUT = str(_ROOT / "src" / "socketify" / "libsocketify.so")
# NATIVE_CAPI_DIR = str(_ROOT / "build" / "native")
# NATIVE_LIB_PATH = str(_ROOT / "build" / "libsocketify.so")
# NATIVE_DIR = str(_ROOT / "src" / "socketify" /"native")
# NATIVE_BUILD_DIR = str(_ROOT / "build" /"native")
# NATIVE_LIB_OUTPUT = str(_ROOT / "src" / "socketify" / "libsocketify.so")
class Prepare(sdist):
def run(self):
super().run()
# class Prepare(sdist):
# def run(self):
# super().run()
class Makefile(build_ext):
def run(self):
env = os.environ.copy()
# class Makefile(build_ext):
# def run(self):
# env = os.environ.copy()
if os.path.exists(UWS_BUILD_DIR):
shutil.rmtree(UWS_BUILD_DIR)
shutil.copytree(UWS_DIR, UWS_BUILD_DIR)
# if os.path.exists(UWS_BUILD_DIR):
# shutil.rmtree(UWS_BUILD_DIR)
# shutil.copytree(UWS_DIR, UWS_BUILD_DIR)
if os.path.exists(NATIVE_CAPI_DIR):
shutil.rmtree(NATIVE_CAPI_DIR)
shutil.copytree(NATIVE_DIR, NATIVE_CAPI_DIR)
# if os.path.exists(NATIVE_CAPI_DIR):
# shutil.rmtree(NATIVE_CAPI_DIR)
# shutil.copytree(NATIVE_DIR, NATIVE_CAPI_DIR)
subprocess.run(["make", "shared"], cwd=NATIVE_CAPI_DIR, env=env, check=True)
shutil.move(NATIVE_LIB_PATH, NATIVE_LIB_OUTPUT)
# subprocess.run(["make", "shared"], cwd=NATIVE_CAPI_DIR, env=env, check=True)
# shutil.move(NATIVE_LIB_PATH, NATIVE_LIB_OUTPUT)
super().run()
# super().run()
with open("README.md", "r", encoding="utf-8") as fh:
@ -81,6 +81,7 @@ setuptools.setup(
python_requires=">=3.7",
install_requires=["cffi>=1.0.0", "setuptools>=60.0.0"],
has_ext_modules=lambda: True,
cmdclass={'sdist': Prepare, 'build_ext': Makefile},
cmdclass={}, #cmdclass={'sdist': Prepare, 'build_ext': Makefile},
include_package_data=True
)

Wyświetl plik

@ -1,24 +0,0 @@
import datetime
class MemoryCacheItem:
def __init__(self, expires, value):
self.expires = datetime.datetime.utcnow().timestamp() + expires
self.value = value
def is_expired(self):
return datetime.datetime.utcnow().timestamp() > self.expires
class MemoryCache:
def __init__(self):
self.cache = {}
def setex(self, key, expires, value):
self.cache[key] = MemoryCacheItem(expires, value)
def get(self, key):
try:
cache = self.cache[key]
if cache.is_expired():
return None
return cache.value
except KeyError:
return None

Wyświetl plik

@ -1,70 +0,0 @@
import asyncio
from .memory_cache import MemoryCache
# 2 LEVEL CACHE (Redis to share amoung worker, Memory to be much faster)
class TwoLevelCache:
def __init__(self, redis_conection, memory_expiration_time=3, redis_expiration_time=10):
self.memory_cache = MemoryCache()
self.redis_conection = redis_conection
self.memory_expiration_time = memory_expiration_time
self.redis_expiration_time = redis_expiration_time
#set cache to redis and memory
def set(self, key, data):
try:
#never cache invalid data
if data == None:
return False
self.redis_conection.setex(key, self.redis_expiration_time, data)
self.memory_cache.setex(key, self.memory_expiration_time, data)
return True
except Exception as err:
print(err)
return False
def get(self, key):
try:
value = self.memory_cache.get(key)
if value != None:
return value
#no memory cache so, got to redis
value = self.redis_conection.get(key)
if value != None:
#refresh memory cache to speed up
self.memory_cache.setex(key, self.memory_expiration_time, data)
return value
except Exception as err:
return None
#if more than 1 worker/request try to do this request, only one will call the Model and the others will get from cache
async def run_once(self, key, timeout, executor, *args):
result = None
try:
lock = self.redis_conection.lock(f"lock-{key}", blocking_timeout=timeout)
#wait lock (some request is yeat not finish)
while lock.locked():
await asyncio.sleep(0)
try:
lock.acquire(blocking=False)
#always check cache first
cached = self.get(key)
if cached != None:
return cached
result = await executor(*args)
if result != None:
self.set(key, result)
except Exception as err:
# the lock wasn't acquired
pass
finally:
lock.release()
except Exception as err:
#cannot even create or release the lock
pass
finally:
#if result is None, try cache one last time
if result == None:
cache = self.get(key)
if cache != None:
return cache
return result

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Plik binarny nie jest wyświetlany.

Wyświetl plik

@ -0,0 +1,26 @@
@REM #download dependences
vcpkg install libuv zlib --triplet x64-windows
vcpkg install zlib:x64-windows-static
vcpkg install libevent:x64-windows-static
vcpkg integrate install
cp C:\vcpkg\installed\x64-windows\bin\uv.dll ..\uv.dll
@REM # build boringssl
cd ../uWebSockets/uSockets/boringssl
mkdir amd64
cd amd64
cmake -DCMAKE_BUILD_TYPE=Release -GNinja .. && ninja crypto ssl
cd ../../lsquic
@REM # build lsquic
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBORINGSSL_DIR=../boringssl -DCMAKE_BUILD_TYPE=Release -DLSQUIC_BIN=Off . && msbuild ALL_BUILD.vcxproj
cd ../../../native
@REM # build uWebSockets
cd ../uWebSockets/uSockets
clang -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -D WIN32_LEAN_AND_MEAN -I lsquic/wincompat -I C:/vcpkg/packages/libuv_x64-windows/include -I src -I lsquic/include -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -std=c11 -O3 -c src/*.c src/eventing/*.c src/crypto/*.c -L C:/vcpkg/packages/libuv_x64-windows/lib
clang++ -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -D WIN32_LEAN_AND_MEAN -I lsquic/wincompat -I C:/vcpkg/packages/libuv_x64-windows/include -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -std=c++2a -O3 -c src/crypto/*.cpp -L C:/vcpkg/packages/zlib_x64-windows/lib
ar rvs uSockets_windows_amd64.a *.o
cd ../../native
@REM # build CAPI + libsocketify
clang++ -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -D WIN32_LEAN_AND_MEAN -I C:/vcpkg/packages/zlib_x64-windows/include -I C:/vcpkg/packages/libuv_x64-windows/include -I ./src -I ../uWebSockets/src -I ../uWebSockets/uSockets/src -I ../uWebSockets/capi -I ../uWebSockets/uSockets/lsquic/wincompat -I ../uWebSockets/uSockets/lsquic/include -I ../uWebSockets/uSockets/boringssl/include -pthread -std=c++2a -c -O3 ./src/libsocketify.cpp -L C:/vcpkg/packages/libuv_x64-windows/lib
clang++ -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -shared -o ../libsocketify_windows_amd64.dll libsocketify.o ../uWebSockets/uSockets/uSockets_windows_amd64.a ../uWebSockets/uSockets/boringssl/amd64/ssl/ssl.lib ../uWebSockets/uSockets/boringssl/amd64/crypto/crypto.lib C:/vcpkg/packages/zlib_x64-windows/lib/zlib.lib ../uWebSockets/uSockets/lsquic/src/liblsquic/Debug/lsquic.lib -luv -L C:/vcpkg/packages/libuv_x64-windows/lib

Wyświetl plik

@ -1,22 +1,68 @@
LIBRARY_NAME := libsocketify
UWS_LIBRARY_NAME := libuwebsockets
CC := clang
CXX := clang++
ARCH := amd64
ifeq ($(PLATFORM), arm64)
ARCH := arm64
endif
ifeq ($(PLATFORM), arm)
ARCH := arm64
endif
clean:
cd ../uWebSockets/uSockets && rm -f *.o $(LIBRARY_NAME).a $(LIBRARY_NAME).so $(UWS_LIBRARY_NAME).a $(UWS_LIBRARY_NAME).so
cd ../uWebSockets/ && rm -f *.o $(LIBRARY_NAME).a $(LIBRARY_NAME).so $(UWS_LIBRARY_NAME).a $(UWS_LIBRARY_NAME).so
rm -f *.o $(LIBRARY_NAME).a $(LIBRARY_NAME).so $(UWS_LIBRARY_NAME).a $(UWS_LIBRARY_NAME).so
shared:
cd ../uWebSockets/uSockets && rm -f *.o *.a *.so *.obj *.lib *.dll
cd ../uWebSockets/ && rm -f *.o *.a *.so *.obj *.lib *.dll
rm -f *.o *.a *.so *.dll *.obj *.lib
rm -rf ../uWebSockets/uSockets/boringssl/amd64
rm -rf ../uWebSockets/uSockets/boringssl/vcpkg
rm -rf ../uWebSockets/uSockets/boringssl/arm64
macos:
$(MAKE) clean
# build boringssl
cd ../uWebSockets/uSockets/boringssl && mkdir -p amd64 && cd amd64 && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.14 .. && make crypto ssl
# build boringssl for arm64 (cross compile)
cd ../uWebSockets/uSockets/boringssl && mkdir -p arm64 && cd arm64 && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 .. && make crypto ssl
# build lsquic
cd ../uWebSockets/uSockets/lsquic && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBORINGSSL_DIR=../boringssl -DCMAKE_BUILD_TYPE=Release -DLSQUIC_BIN=Off . && make lsquic
# build uWebSockets
cd ../uWebSockets/uSockets && $(CC) -pthread -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -std=c11 -Isrc -flto -fPIC -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
cd ../uWebSockets/uSockets && $(CXX) -std=c++17 -flto -fPIC -O3 -c src/crypto/*.cpp
cd ../uWebSockets/uSockets && $(AR) rvs uSockets.a *.o
cd ../uWebSockets/uSockets && $(CC) -mmacosx-version-min=10.14 -I src -I lsquic/include -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c11 -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
cd ../uWebSockets/uSockets && $(CXX) -stdlib=libc++ -mmacosx-version-min=10.14 -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c++17 -O3 -c src/crypto/*.cpp
cd ../uWebSockets/uSockets && $(AR) rvs uSockets_darwin_amd64.a *.o
# build uWebSockets for arm64 (cross compile)
cd ../uWebSockets/uSockets && $(CC) -target arm64-apple-macos11 -I src -I lsquic/include -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c11 -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
cd ../uWebSockets/uSockets && $(CXX) -stdlib=libc++ -target arm64-apple-macos11 -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c++17 -O3 -c src/crypto/*.cpp
cd ../uWebSockets/uSockets && $(AR) rvs uSockets_darwin_arm64.a *.o
# build CAPI + libsocketify
$(CXX) -c -O1 -std=c++17 -lz -luv -flto -fPIC -I ./src -I ../uWebSockets/src -I ../uWebSockets/uSockets/src -I ../uWebSockets/capi ./src/$(LIBRARY_NAME).cpp
$(CXX) -shared -o ../$(LIBRARY_NAME).so $(LIBRARY_NAME).o ../uWebSockets/uSockets/uSockets.a -fPIC -lz -luv -lssl -lcrypto
$(CXX) -stdlib=libc++ -mmacosx-version-min=10.14 -I ./src -I ../uWebSockets/src -I ../uWebSockets/uSockets/src -I ../uWebSockets/capi -I ../uWebSockets/uSockets/lsquic/include -I ../uWebSockets/uSockets/boringssl/include -pthread -fPIC -std=c++17 -c -O3 ./src/$(LIBRARY_NAME).cpp
$(CXX) -stdlib=libc++ -mmacosx-version-min=10.14 -shared -undefined dynamic_lookup -o ../$(LIBRARY_NAME)_darwin_amd64.so $(LIBRARY_NAME).o ../uWebSockets/uSockets/uSockets_darwin_amd64.a ../uWebSockets/uSockets/boringssl/amd64/ssl/libssl.a ../uWebSockets/uSockets/boringssl/amd64/crypto/libcrypto.a ../uWebSockets/uSockets/lsquic/src/liblsquic/liblsquic.a -flto -fPIC -lz -luv
rm -f *.o
# build CAPI + libsocketify for arm64 (cross compile)
$(CXX) -stdlib=libc++ -target arm64-apple-macos11 -I ./src -I ../uWebSockets/src -I ../uWebSockets/uSockets/src -I ../uWebSockets/capi -I ../uWebSockets/uSockets/lsquic/include -I ../uWebSockets/uSockets/boringssl/include -pthread -fPIC -std=c++17 -c -O3 ./src/$(LIBRARY_NAME).cpp
$(CXX) -stdlib=libc++ -target arm64-apple-macos11 -shared -undefined dynamic_lookup -o ../$(LIBRARY_NAME)_darwin_arm64.so $(LIBRARY_NAME).o ../uWebSockets/uSockets/uSockets_darwin_amd64.a ../uWebSockets/uSockets/boringssl/amd64/ssl/libssl.a ../uWebSockets/uSockets/boringssl/amd64/crypto/libcrypto.a ../uWebSockets/uSockets/lsquic/src/liblsquic/liblsquic.a -flto -fPIC -lz -luv
linux:
$(MAKE) clean
# build boringssl
cd ../uWebSockets/uSockets/boringssl && mkdir -p ${ARCH} && cd ${ARCH} && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Release .. && make crypto ssl
# build lsquic
cd ../uWebSockets/uSockets/lsquic && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBORINGSSL_DIR=../boringssl -DCMAKE_BUILD_TYPE=Release -DLSQUIC_BIN=Off . && make lsquic
# build uWebSockets
cd ../uWebSockets/uSockets && $(CC) -I src -I lsquic/include -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c11 -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
cd ../uWebSockets/uSockets && $(CXX) -I boringssl/include -DUWS_WITH_PROXY -DLIBUS_USE_OPENSSL -DLIBUS_USE_LIBUV -DLIBUS_USE_QUIC -pthread -fPIC -std=c++17 -O3 -c src/crypto/*.cpp
cd ../uWebSockets/uSockets && $(AR) rvs uSockets_linux_$(ARCH).a *.o
# build CAPI + libsocketify
$(CXX) -I ./src -I ../uWebSockets/src -I ../uWebSockets/uSockets/src -I ../uWebSockets/capi -I ../uWebSockets/uSockets/lsquic/include -I ../uWebSockets/uSockets/boringssl/include -pthread -fPIC -std=c++17 -c -O3 ./src/$(LIBRARY_NAME).cpp
$(CXX) -shared -static-libstdc++ -static-libgcc -s -o ../$(LIBRARY_NAME)_linux_amd64.so $(LIBRARY_NAME).o ../uWebSockets/uSockets/uSockets_linux_$(ARCH).a ../uWebSockets/uSockets/boringssl/$(ARCH)/ssl/libssl.a ../uWebSockets/uSockets/boringssl/$(ARCH)/crypto/libcrypto.a ../uWebSockets/uSockets/lsquic/src/liblsquic/liblsquic.a -flto -fPIC -lz -luv

Wyświetl plik

@ -2,7 +2,6 @@
#include "libsocketify.h"
#include <stdlib.h>
#include <stdio.h>
#include "libuwebsockets.h"
#include "libuwebsockets.cpp" //include symbols
extern "C"

Wyświetl plik

@ -2,30 +2,29 @@
#define SOCKETIFY_CAPI_HEADER
#include "uv.h"
#include <stdbool.h>
#include "libuwebsockets.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "libuwebsockets.h"
typedef void (*socketify_prepare_handler)(void* user_data);
typedef void (*socketify_timer_handler)(void* user_data);
DLL_EXPORT typedef void (*socketify_prepare_handler)(void* user_data);
DLL_EXPORT typedef void (*socketify_timer_handler)(void* user_data);
typedef enum {
DLL_EXPORT typedef enum {
SOCKETIFY_RUN_DEFAULT = 0,
SOCKETIFY_RUN_ONCE,
SOCKETIFY_RUN_NOWAIT
} socketify_run_mode;
typedef struct {
DLL_EXPORT typedef struct {
void* uv_prepare_ptr;
socketify_prepare_handler on_prepare_handler;
void* on_prepare_data;
void* uv_loop;
} socketify_loop;
typedef struct{
DLL_EXPORT typedef struct{
void* uv_timer_ptr;
socketify_timer_handler handler;
void* user_data;
@ -33,22 +32,22 @@ typedef struct{
socketify_loop * socketify_create_loop();
bool socketify_constructor_failed(socketify_loop* loop);
bool socketify_on_prepare(socketify_loop* loop, socketify_prepare_handler handler, void* user_data);
bool socketify_prepare_unbind(socketify_loop* loop);
void socketify_destroy_loop(socketify_loop* loop);
void* socketify_get_native_loop(socketify_loop* loop);
DLL_EXPORT socketify_loop * socketify_create_loop();
DLL_EXPORT bool socketify_constructor_failed(socketify_loop* loop);
DLL_EXPORT bool socketify_on_prepare(socketify_loop* loop, socketify_prepare_handler handler, void* user_data);
DLL_EXPORT bool socketify_prepare_unbind(socketify_loop* loop);
DLL_EXPORT void socketify_destroy_loop(socketify_loop* loop);
DLL_EXPORT void* socketify_get_native_loop(socketify_loop* loop);
int socketify_loop_run(socketify_loop* loop, socketify_run_mode mode);
void socketify_loop_stop(socketify_loop* loop);
DLL_EXPORT int socketify_loop_run(socketify_loop* loop, socketify_run_mode mode);
DLL_EXPORT void socketify_loop_stop(socketify_loop* loop);
socketify_timer* socketify_create_timer(socketify_loop* loop, uint64_t timeout, uint64_t repeat, socketify_timer_handler handler, void* user_data);
void socketify_timer_destroy(socketify_timer* timer);
void socketify_timer_set_repeat(socketify_timer* timer, uint64_t repeat);
DLL_EXPORT socketify_timer* socketify_create_timer(socketify_loop* loop, uint64_t timeout, uint64_t repeat, socketify_timer_handler handler, void* user_data);
DLL_EXPORT void socketify_timer_destroy(socketify_timer* timer);
DLL_EXPORT void socketify_timer_set_repeat(socketify_timer* timer, uint64_t repeat);
socketify_timer* socketify_create_check(socketify_loop* loop, socketify_timer_handler handler, void* user_data);
void socketify_check_destroy(socketify_timer* timer);
DLL_EXPORT socketify_timer* socketify_create_check(socketify_loop* loop, socketify_timer_handler handler, void* user_data);
DLL_EXPORT void socketify_check_destroy(socketify_timer* timer);
#endif
#ifdef __cplusplus
}

Wyświetl plik

@ -227,7 +227,10 @@ void uws_req_for_each_header(uws_req_t *res, uws_get_headers_server_handler hand
""")
library_path = os.path.join(os.path.dirname(__file__), "libsocketify.so")
library_extension = "dll" if platform.system().lower() == "windows" else "so"
library_path = os.path.join(os.path.dirname(__file__), "libsocketify_%s_%s.%s" % (platform.system().lower(), "arm64" if "arm" in platform.processor().lower() else "amd64", library_extension))
lib = ffi.dlopen(library_path)
@ffi.callback("void(const char *, size_t, const char *, size_t, void *)")

@ -1 +1 @@
Subproject commit b5f0a8a07a89ea13b08785d7a65c33036bc53cda
Subproject commit 12eea90206165d6fd58e017b40b376c8c667c6e4

Wyświetl plik

@ -1,6 +1,7 @@
import cffi
import os
import platform
ffi = cffi.FFI()
ffi.cdef("""
@ -54,7 +55,8 @@ void socketify_timer_set_repeat(socketify_timer* timer, uint64_t repeat);
socketify_timer* socketify_create_check(socketify_loop* loop, socketify_timer_handler handler, void* user_data);
void socketify_check_destroy(socketify_timer* timer);
""")
library_path = os.path.join(os.path.dirname(__file__), "libsocketify.so")
library_extension = "dll" if platform.system().lower() == "windows" else "so"
library_path = os.path.join(os.path.dirname(__file__), "libsocketify_%s_%s.%s" % (platform.system().lower(), "arm64" if "arm" in platform.processor().lower() else "amd64", library_extension))
lib = ffi.dlopen(library_path)