~ubuntu-branches/ubuntu/vivid/pyzmq/vivid

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Bazaar Package Importer
  • Author(s): Miguel Landaeta
  • Date: 2010-09-08 13:50:41 UTC
  • Revision ID: james.westby@ubuntu.com-20100908135041-bogeb6ykukjrcd89
Tags: upstream-0.1.20100703+git18f5d06155
ImportĀ upstreamĀ versionĀ 0.1.20100703+git18f5d06155

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
#
 
4
#    Copyright (c) 2010 Brian E. Granger
 
5
#
 
6
#    This file is part of pyzmq.
 
7
#
 
8
#    pyzmq is free software; you can redistribute it and/or modify it under
 
9
#    the terms of the Lesser GNU General Public License as published by
 
10
#    the Free Software Foundation; either version 3 of the License, or
 
11
#    (at your option) any later version.
 
12
#
 
13
#    pyzmq is distributed in the hope that it will be useful,
 
14
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
#    Lesser GNU General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the Lesser GNU General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
 
 
22
#-----------------------------------------------------------------------------
 
23
# Imports
 
24
#-----------------------------------------------------------------------------
 
25
 
 
26
import os, sys
 
27
 
 
28
from distutils.core import setup, Command
 
29
from distutils.extension import Extension
 
30
 
 
31
from unittest import TextTestRunner, TestLoader
 
32
from glob import glob
 
33
from os.path import splitext, basename, join as pjoin, walk
 
34
 
 
35
 
 
36
#-----------------------------------------------------------------------------
 
37
# Extra commands
 
38
#-----------------------------------------------------------------------------
 
39
 
 
40
class TestCommand(Command):
 
41
    """Custom distutils command to run the test suite."""
 
42
 
 
43
    user_options = [ ]
 
44
 
 
45
    def initialize_options(self):
 
46
        self._dir = os.getcwd()
 
47
 
 
48
    def finalize_options(self):
 
49
        pass
 
50
 
 
51
    def run(self):
 
52
        """Finds all the tests modules in zmq/tests/, and runs them."""
 
53
        testfiles = [ ]
 
54
        for t in glob(pjoin(self._dir, 'zmq', 'tests', '*.py')):
 
55
            if not t.endswith('__init__.py'):
 
56
                testfiles.append('.'.join(
 
57
                    ['zmq.tests', splitext(basename(t))[0]])
 
58
                )
 
59
        tests = TestLoader().loadTestsFromNames(testfiles)
 
60
        t = TextTestRunner(verbosity = 1)
 
61
        t.run(tests)
 
62
 
 
63
 
 
64
class CleanCommand(Command):
 
65
    """Custom distutils command to clean the .so and .pyc files."""
 
66
 
 
67
    user_options = [ ]
 
68
 
 
69
    def initialize_options(self):
 
70
        self._clean_me = [pjoin('zmq', '_zmq.so') ]
 
71
        for root, dirs, files in os.walk('.'):
 
72
            for f in files:
 
73
                if f.endswith('.pyc'):
 
74
                    self._clean_me.append(pjoin(root, f))
 
75
 
 
76
    def finalize_options(self):
 
77
        pass
 
78
 
 
79
    def run(self):
 
80
        for clean_me in self._clean_me:
 
81
            try:
 
82
                os.unlink(clean_me)
 
83
            except:
 
84
                pass
 
85
 
 
86
#-----------------------------------------------------------------------------
 
87
# Extensions
 
88
#-----------------------------------------------------------------------------
 
89
 
 
90
cmdclass = {'test':TestCommand, 'clean':CleanCommand }
 
91
 
 
92
try:
 
93
    from Cython.Distutils import build_ext
 
94
except ImportError:
 
95
    zmq_source = os.path.join('zmq','_zmq.c')
 
96
else:
 
97
    zmq_source = os.path.join('zmq','_zmq.pyx')
 
98
    cmdclass['build_ext'] =  build_ext
 
99
 
 
100
if sys.platform == 'win32':
 
101
    libzmq = 'libzmq'
 
102
else:
 
103
    libzmq = 'zmq'
 
104
 
 
105
zmq = Extension(
 
106
    'zmq._zmq',
 
107
    sources = [zmq_source],
 
108
    libraries = [libzmq]
 
109
)
 
110
 
 
111
#-----------------------------------------------------------------------------
 
112
# Main setup
 
113
#-----------------------------------------------------------------------------
 
114
 
 
115
setup(
 
116
    name = "pyzmq",
 
117
    version = "0.1",
 
118
    packages = ['zmq', 'zmq.tests', 'zmq.eventloop'],
 
119
    ext_modules = [zmq],
 
120
    author = "Brian E. Granger",
 
121
    author_email = "ellisonbg@gmail.com",
 
122
    description = "Cython based Python bindings for 0MQ.",
 
123
    license = "LGPL",
 
124
    cmdclass = cmdclass
 
125
)
 
126