File: setup.py

package info (click to toggle)
python-wsaccel 0.6.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 160 kB
  • sloc: python: 370; makefile: 41; ansic: 16
file content (81 lines) | stat: -rw-r--r-- 2,548 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
import io
import os
import sys
import subprocess
try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup, Extension

from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist


class NoCython(Exception):
    pass

def cythonize(src):
    sys.stderr.write("cythonize: %r\n" % (src,))
    subprocess.check_call("cython3 %s" % (src,), shell=True)

def ensure_source(src):
    pyx = os.path.splitext(src)[0]   '.pyx'
    if os.path.exists(pyx):
        if not os.path.exists(src) \
           or os.stat(src).st_mtime < os.stat(pyx).st_mtime:
            cythonize(pyx)
    return src


class BuildExt(build_ext):
    def build_extension(self, ext):
        try:
            ext.sources = list(map(ensure_source, ext.sources))
        except NoCython:
            print("Cython is required for building extension from checkout.")
            print("Install Cython >= 0.16 or install ws4py from PyPI.")
            raise
        return build_ext.build_extension(self, ext)


class Sdist(sdist):
    def __init__(self, *args, **kwargs):
        cythonize('wsaccel/utf8validator.pyx')
        cythonize('wsaccel/xormask.pyx')
        sdist.__init__(self, *args, **kwargs)

ext_modules = [
    Extension('wsaccel.utf8validator', ['wsaccel/utf8validator.c']),
    Extension('wsaccel.xormask', ['wsaccel/xormask.c']),
]

with io.open('README.rst', encoding='utf-8') as f:
    long_description = f.read()

setup(name="wsaccel",
      version='0.6.3',
      description="Accelerator for ws4py and AutobahnPython",
      maintainer="Inada Naoki",
      maintainer_email="[email protected]",
      url="https://github.com/methane/wsaccel",
      packages=["wsaccel"],
      cmdclass={'build_ext': BuildExt, 'sdist': Sdist},
      ext_modules=ext_modules,
      platforms=["any"],
      license='Apache',
      long_description=long_description,
      classifiers=[
          'Intended Audience :: Developers',
          'Operating System :: OS Independent',
          'Programming Language :: Python',
          'Programming Language :: Python :: 2',
          'Programming Language :: Python :: 2.7',
          'Programming Language :: Python :: 3',
          'Programming Language :: Python :: 3.6',
          'Programming Language :: Python :: 3.7',
          'Programming Language :: Python :: 3.8',
          'Programming Language :: Python :: 3.9',
          'Programming Language :: Python :: Implementation :: CPython',
          ],
      )