From 5e2e0e0d3db82556fb49e51a36ab288df2bd2797 Mon Sep 17 00:00:00 2001 From: Ciro Date: Sat, 28 May 2022 19:49:16 -0300 Subject: [PATCH] try to fix pypy build --- .gitignore | 6 +++--- .gitmodules | 2 +- README.md | 6 +++--- setup.py | 26 ++++++++++++++++++-------- uWebSockets | 1 - 5 files changed, 25 insertions(+), 16 deletions(-) delete mode 160000 uWebSockets diff --git a/.gitignore b/.gitignore index 11aeb1d..1e87114 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ __pycache__ +/src/socketify/uWebSockets /src/socketify.egg-info -/build/ -/dist/ -/uWebSockets/ +/build +/dist /src/socketify/*.so *.so \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 09086d4..7eb849d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "uWebSockets"] - path = uWebSockets + path = src/socketify/uWebSockets url = https://github.com/cirospaciari/uWebSockets branch = capi-complete-with-ssl-and-samples \ No newline at end of file diff --git a/README.md b/README.md index c146a7b..8e80b1c 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,9 @@ app.run() ### pip install ```bash -pip install git+https://github.com/cirospaciari/socketify.py.git +pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext #or specify PyPy3 -pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git +pypy3 -m pip install git+https://github.com/cirospaciari/socketify.py.git --global-option=build_ext ``` ### Run @@ -46,7 +46,7 @@ git submodule update --init --recursive --remote pypy3 -m pip install --upgrade build #build and install pypy3 -m build -pypy3 -m pip install . +pypy3 -m pip install . --no-cache-dir --global-option=build_ext #if you want to remove pypy3 -m pip uninstall socketify ``` \ No newline at end of file diff --git a/setup.py b/setup.py index 34ae04b..99e4845 100644 --- a/setup.py +++ b/setup.py @@ -9,21 +9,30 @@ if sys.platform in ('win32', 'cygwin', 'cli'): import setuptools from setuptools.command.sdist import sdist +from setuptools.command.build_ext import build_ext + 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_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_DIR = str(_ROOT / "src" / "socketify" /"uWebSockets") +UWS_BUILD_DIR = str(_ROOT / "build" /"uWebSockets") UWS_LIB_OUTPUT = str(_ROOT / "src" / "socketify" / "libuwebsockets.so") -class Makefile(sdist): +class Prepare(sdist): + def run(self): + super().run() + +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) @@ -55,11 +64,12 @@ setuptools.setup( "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], + packages=["socketify"], package_dir={"": "src"}, - package_data={"": ['./libuwebsockets.so']}, - packages=setuptools.find_packages(where="src"), + package_data={"": ['./*.so', './uWebSockets/*','./uWebSockets/*/*','./uWebSockets/*/*/*']}, python_requires=">=3.7", - cmdclass={'sdist': Makefile}, - include_package_data=True, - install_requires=[] + install_requires=["cffi>=1.0.0"], + has_ext_modules=lambda: True, + cmdclass={'sdist': Prepare,'build_ext': Makefile}, + include_package_data=True ) \ No newline at end of file diff --git a/uWebSockets b/uWebSockets deleted file mode 160000 index fd78f29..0000000 --- a/uWebSockets +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fd78f2960ac3c8ac529a11f115ba824db7e60c09