File: setup.py

package info (click to toggle)
m2ext 0.1-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 76 kB
  • sloc: python: 68; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 2,152 bytes parent folder | download | duplicates (4)
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
from distutils.core import setup
from distutils.command import build_ext
from distutils.core import Extension

import os, sys


def load_description():
    try:
        f = open('README.rst', 'r')
        description = f.read()
        f.close()
        return description
    except:
        return ""


class OpensslBuilder(build_ext.build_ext):
    """
    Specialization of build_ext to enable swig_opts to inherit any
    include_dirs settings made at the command line or in a setup.cfg
    file
    """

    user_options = build_ext.build_ext.user_options + [
        ('openssl=', 'o', 'Prefix for openssl installation location'),
        ('swig-extra=', None, 'Extra swig options')]
    
    def initialize_options(self):
        build_ext.build_ext.initialize_options(self)
        self.swig_extra = None
        if os.name == 'nt':
            self.libraries = ['ssleay32', 'libeay32']
            self.openssl = 'c:\\pkg'
        else:
            self.libraries = ['ssl', 'crypto']
            self.openssl = '/usr'

    def finalize_options(self):
        build_ext.build_ext.finalize_options(self)

        openssl_include = os.path.join(self.openssl, 'include')
        openssl_lib = os.path.join(self.openssl, 'lib')

        self.swig_opts = ['-I%s' % i for i in self.include_dirs + [openssl_include]] + ['-includeall', '-noproxy']
        if self.swig_extra is not None:
            if hasattr(self.swig_extra, 'pop'):
                self.swig_opts.extend(self.swig_extra)
            else:
                self.swig_opts.append(self.swig_extra)

        self.include_dirs.append(openssl_include)
        self.library_dirs.append(openssl_lib)

m2ext = Extension(name="m2ext._m2ext",
                  sources=["swig/m2ext.i"],
                  extra_compile_args=["-DTHREADING"])

setup(
    name='m2ext',
    version='0.1',
    description='M2Crypto Extensions',
    long_description=load_description(),
    author='Lev Shamardin',
    author_email='shamardin@gmail.com',
    license='BSD',
    url='https://github.com/abbot/m2ext',
    ext_modules = [m2ext],
    packages=["m2ext"],
    cmdclass = {'build_ext': OpensslBuilder},
)