From c0d23e27e4b94ee549d3dd5918fdc89bd91171ca Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Mon, 17 Sep 2012 14:06:51 -0500 Subject: [PATCH] Refactor into python modules: websocket, websocketproxy Make websockify subdirectory and move websocket.py -> websockify/websocket.py and websockify -> websockify/websocketproxy.py. Create a ./run script that launches websockify as before (unfortunately can't have a websockify script at the same level since this is now a directory). Make websockify.py a symlink to ./run. Once the package is installed, the main launch script will be /usr/bin/websockify. This makes it easier to package up websockify as a python module. setup.py should now properly install websockify as a module. Note that to include the base websocket module/class you will now do: import websockify.websocket #OR from websockify.websocket import WebSocketServer To import the full websocket proxy functionality: import websockify.websocketproxy #OR from websockify.websocket import WebSocketProxy This will also help with startup speed slightly because the code in websocketproxy will now be byte compiled since it is no longer in the main invocation script. --- run | 5 +++++ setup.py | 4 ++-- websockify.py | 2 +- websockify/__init__.py | 1 + websocket.py => websockify/websocket.py | 0 websockify => websockify/websocketproxy.py | 0 6 files changed, 9 insertions(+), 3 deletions(-) create mode 100755 run create mode 100644 websockify/__init__.py rename websocket.py => websockify/websocket.py (100%) rename websockify => websockify/websocketproxy.py (100%) diff --git a/run b/run new file mode 100755 index 0000000..54db9b8 --- /dev/null +++ b/run @@ -0,0 +1,5 @@ +#!/usr/bin/python + +import websockify + +websockify.websocketproxy.websockify_init() diff --git a/setup.py b/setup.py index 642dbc4..947f0a5 100644 --- a/setup.py +++ b/setup.py @@ -18,13 +18,13 @@ setup(name=name, author="Joel Martin", author_email="github@martintribe.org", - packages=find_packages(), + packages=['websockify'], include_package_data=True, install_requires=['numpy'], zip_safe=False, entry_points={ 'console_scripts': [ - 'websockify = websockify:websockify_init', + 'websockify = websockify.websocketproxy:websockify_init', ] }, ) diff --git a/websockify.py b/websockify.py index 05b5af4..e5224d5 120000 --- a/websockify.py +++ b/websockify.py @@ -1 +1 @@ -websockify \ No newline at end of file +run \ No newline at end of file diff --git a/websockify/__init__.py b/websockify/__init__.py new file mode 100644 index 0000000..9e75803 --- /dev/null +++ b/websockify/__init__.py @@ -0,0 +1 @@ +import websocket, websocketproxy diff --git a/websocket.py b/websockify/websocket.py similarity index 100% rename from websocket.py rename to websockify/websocket.py diff --git a/websockify b/websockify/websocketproxy.py similarity index 100% rename from websockify rename to websockify/websocketproxy.py