pull/39/head
Ciro 2022-05-28 16:59:08 -03:00
rodzic b6f2572372
commit d75bd98385
12 zmienionych plików z 89 dodań i 6 usunięć

6
.gitignore vendored
Wyświetl plik

@ -1 +1,5 @@
__pycache__
__pycache__
/src/socketify.egg-info
/build/
/dist/
/uWebSockets/

4
.gitmodules vendored 100644
Wyświetl plik

@ -0,0 +1,4 @@
[submodule "uWebSockets"]
path = uWebSockets
url = https://github.com/cirospaciari/uWebSockets
branch = capi-complete-with-ssl-and-samples

Wyświetl plik

@ -9,7 +9,7 @@ from socketify import App
app = App()
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
app.listen(3000, lambda socket, config: print("Listening on port http://localhost:%d now\n" % config.port))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()
```
@ -30,6 +30,6 @@ from socketify import App, AppOptions
app = App(AppOptions(key_file_name="./misc/key.pem", cert_file_name="./misc/cert.pem", passphrase="1234"))
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
app.listen(3000, lambda socket, config: print("Listening on port http://localhost:%d now\n" % config.port))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()
```

65
setup.py 100644
Wyświetl plik

@ -0,0 +1,65 @@
import sys
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')
import setuptools
from setuptools.command.sdist import sdist
import pathlib
import os
import shutil
import subprocess
_ROOT = pathlib.Path(__file__).parent
UWS_DIR = str(_ROOT / "uWebSockets")
UWS_CAPI_DIR = str(_ROOT / "build" / "uWebSockets" / "capi")
UWS_LIB_PATH = str(_ROOT / "build" / "uWebSockets" / "capi" / "libuwebsockets.so")
UWS_BUILD_DIR = str(_ROOT / "build"/ "uWebSockets")
UWS_LIB_OUTPUT = str(_ROOT / "src" / "socketify" / "libuwebsockets.so")
class Makefile(sdist):
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)
subprocess.run(["make", "shared"], cwd=UWS_CAPI_DIR, env=env, check=True)
shutil.move(UWS_LIB_PATH, UWS_LIB_OUTPUT)
super().run()
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setuptools.setup(
name="socketify",
version="0.0.1",
platforms=['macOS', 'POSIX'],
author="Ciro Spaciari",
author_email="ciro.spaciari@gmail.com",
description="Fast WebSocket and Http/Https server",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/cirospaciari/socketify.py",
project_urls={
"Bug Tracker": "https://github.com/cirospaciari/issues",
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
package_dir={"": "src"},
package_data={"": ['./libuwebsockets.so']},
packages=setuptools.find_packages(where="src"),
python_requires=">=3.7",
cmdclass={'sdist': Makefile},
include_package_data=True,
install_requires=[]
)

Wyświetl plik

@ -0,0 +1 @@
from .socketify import App, AppOptions, AppListenOptions

Wyświetl plik

@ -1,5 +1,5 @@
import cffi
import os
ffi = cffi.FFI()
ffi.cdef("""
@ -200,8 +200,9 @@ size_t uws_req_get_query(uws_req_t *res, const char *key, size_t key_length, con
size_t uws_req_get_parameter(uws_req_t *res, unsigned short index, const char **dest);
""")
library_path = os.path.join(os.path.dirname(__file__), "libuwebsockets.so")
lib = ffi.dlopen("./libuwebsockets.so")
lib = ffi.dlopen(library_path)
@ffi.callback("void(uws_res_t *, uws_req_t *, void *)")
def uws_generic_method_handler(res, req, user_data):

Wyświetl plik

@ -118,4 +118,11 @@ run_app()
#pypy3 -m pip install cysimdjson (uses simdjson) is parse only
#pypy3 -m pip install rapidjson (not working with pypy)
#https://github.com/MagicStack/uvloop/issues/380
#https://foss.heptapod.net/pypy/pypy/-/issues/3740
#https://foss.heptapod.net/pypy/pypy/-/issues/3740
#git submodule update --init --recursive --remote
#pypy3 -m pip install --upgrade build
#pypy3 -m build
#pypy3 -m pip install .
#pypy3 -m pip uninstall socketify

1
uWebSockets 160000

@ -0,0 +1 @@
Subproject commit fd78f2960ac3c8ac529a11f115ba824db7e60c09