Skip to content

Commit 57bc35f

Browse files
committed
using what setuptools provide to manage Python version differences
1 parent 997099e commit 57bc35f

1 file changed

Lines changed: 7 additions & 35 deletions

File tree

setup.py

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,20 @@
22
import os, os.path
33
from glob import iglob
44
import sys
5-
try:
6-
from setuptools import setup
7-
except ImportError:
8-
from distutils.core import setup
5+
from setuptools import setup
96

10-
def gather_modules():
11-
"""
12-
Lists all Python modules of the ws4py package.
13-
I wish there was a simpler way but because some
14-
modules use the 'yield from' statement, we
15-
can't simply pass a list of directories to setup
16-
below. Indeed, that would fail to compile
17-
those modules when running Python 2. At the same
18-
time, the MANIFEST doesn't work for bdist commands,
19-
only source distributions. Distutils is beyond
20-
annoying at cryptic at times. If you have a cleaner
21-
way, please do submit a patch as I'd love seeing it.
22-
"""
23-
pjoin = os.path.join
24-
25-
mods = []
26-
for root, dirs, files in os.walk('ws4py'):
27-
if '__pycache__' in dirs:
28-
dirs.remove('__pycache__')
7+
extra = {}
8+
if sys.version_info >= (3,):
9+
extra['use_2to3'] = True
2910

30-
for name in files:
31-
if name.endswith('.py'):
32-
mods.append(pjoin(root, name).replace('.py', ''))
33-
34-
if sys.version_info < (3, 3) or hasattr(sys, 'pypy_version_info'):
35-
mods.remove(pjoin('ws4py', 'async_websocket.py').replace('.py', ''))
36-
mods.remove(pjoin('ws4py', 'server', 'tulipserver.py').replace('.py', ''))
37-
38-
return mods
39-
4011
setup(name = "ws4py",
4112
version = '0.3.3',
4213
description = "WebSocket client and server library for Python 2 and 3 as well as PyPy",
4314
maintainer = "Sylvain Hellegouarch",
4415
maintainer_email = "sh@defuze.org",
4516
url = "https://github.com/Lawouach/WebSocket-for-Python",
4617
download_url = "http://www.defuze.org/oss/ws4py/",
47-
py_modules=gather_modules(),
18+
py_modules=['ws4py', 'ws4py.client', 'ws4py.server'],
4819
platforms = ["any"],
4920
license = 'BSD',
5021
long_description = "WebSocket client and server library for Python 2 and 3 as well as PyPy",
@@ -66,5 +37,6 @@ def gather_modules():
6637
'Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware',
6738
'Topic :: Internet :: WWW/HTTP :: WSGI :: Server',
6839
'Topic :: Software Development :: Libraries :: Python Modules'
69-
],
40+
],
41+
**extra
7042
)

0 commit comments

Comments
 (0)