File: setup.py

package info (click to toggle)
iceweasel 31.6.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,368,576 kB
  • sloc: cpp: 3,692,968; ansic: 1,797,194; python: 193,401; java: 180,622; asm: 133,557; xml: 89,288; sh: 71,748; perl: 22,087; makefile: 21,687; objc: 4,014; yacc: 1,995; pascal: 1,292; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (196 lines) | stat: -rw-r--r-- 7,866 bytes parent folder | download | duplicates (5)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/env python

# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys
import os
import shutil
import fnmatch
try:
    from setuptools import setup, Extension
except ImportError:
    from distutils.core import setup, Extension


def clean():
    """'python setup.py clean' custom command."""
    def rglob(path, pattern):
        return [os.path.join(dirpath, f)
            for dirpath, dirnames, files in os.walk(path)
            for f in fnmatch.filter(files, pattern)]

    for dirname in ('build', 'dist'):
        if os.path.isdir(dirname):
            sys.stdout.write('removing directory: %s\n' % dirname)
            shutil.rmtree(dirname)

    for dirpath, dirnames, files in os.walk('.'):
        if dirpath.endswith(('__pycache__', '.egg-info')):
            sys.stdout.write('removing directory %s\n' % dirpath)
            shutil.rmtree(dirpath)

    for pattern in ['*.py[co]', '*.s[ol]', '*~', '*.orig', '*.rej', '*.swp']:
        for x in rglob('.', pattern):
           sys.stdout.write('removing file %s\n' % x)
           os.remove(x)

def get_version():
    INIT = os.path.abspath(os.path.join(os.path.dirname(__file__),
                           'psutil', '__init__.py'))
    f = open(INIT, 'r')
    try:
        for line in f:
            if line.startswith('__version__'):
                ret = eval(line.strip().split(' = ')[1])
                assert ret.count('.') == 2, ret
                for num in ret.split('.'):
                    assert num.isdigit(), ret
                return ret
        else:
            raise ValueError("couldn't find version string")
    finally:
        f.close()

def get_description():
    README = os.path.abspath(os.path.join(os.path.dirname(__file__), 'README'))
    f = open(README, 'r')
    try:
        return f.read()
    finally:
        f.close()

VERSION = get_version()


# POSIX
if os.name == 'posix':
    posix_extension = Extension('_psutil_posix',
                                sources = ['psutil/_psutil_posix.c'])
# Windows
if sys.platform.startswith("win32"):

    def get_winver():
        maj, min = sys.getwindowsversion()[0:2]
        return '0x0%s' % ((maj * 100) + min)

    extensions = [Extension('_psutil_mswindows',
                            sources=['psutil/_psutil_mswindows.c',
                                     'psutil/_psutil_common.c',
                                     'psutil/arch/mswindows/process_info.c',
                                     'psutil/arch/mswindows/process_handles.c',
                                     'psutil/arch/mswindows/security.c'],
                            define_macros=[('_WIN32_WINNT', get_winver()),
                                           ('_AVAIL_WINVER_', get_winver())],
                            libraries=["psapi", "kernel32", "advapi32",
                                       "shell32", "netapi32", "iphlpapi",
                                       "wtsapi32"],
                            #extra_compile_args=["/Z7"],
                            #extra_link_args=["/DEBUG"]
                            )]
# OS X
elif sys.platform.startswith("darwin"):
    extensions = [Extension('_psutil_osx',
                            sources = ['psutil/_psutil_osx.c',
                                       'psutil/_psutil_common.c',
                                       'psutil/arch/osx/process_info.c'],
                            extra_link_args=['-framework', 'CoreFoundation',
                                             '-framework', 'IOKit']
                            ),
                  posix_extension]
# FreeBSD
elif sys.platform.startswith("freebsd"):
    extensions = [Extension('_psutil_bsd',
                            sources = ['psutil/_psutil_bsd.c',
                                       'psutil/_psutil_common.c',
                                       'psutil/arch/bsd/process_info.c'],
                            libraries=["devstat"],
                            ),
                  posix_extension]
# Linux
elif sys.platform.startswith("linux"):
    extensions = [Extension('_psutil_linux',
                            sources=['psutil/_psutil_linux.c'],
                            ),
                  posix_extension]
# Solaris
elif sys.platform.lower().startswith('sunos'):
    extensions = [Extension('_psutil_sunos',
                            sources=['psutil/_psutil_sunos.c'],
                            libraries=['kstat', 'nsl'],
                            ),
                  posix_extension]
else:
    sys.exit('platform %s is not supported' % sys.platform)


def main():
    # "python setup.py clean" custom command
    if len(sys.argv) > 1 and sys.argv[1] == 'clean':
        return clean()

    setup_args = dict(
        name='psutil',
        version=VERSION,
        download_url="http://psutil.googlecode.com/files/psutil-%s.tar.gz" \
                     % VERSION,
        description='A process and system utilities module for Python',
        long_description=get_description(),
        keywords=['ps', 'top', 'kill', 'free', 'lsof', 'netstat', 'nice',
                  'tty', 'ionice', 'uptime', 'taskmgr', 'process', 'df',
                  'iotop', 'iostat', 'ifconfig', 'taskset', 'who', 'pidof',
                  'pmap', 'smem', 'monitoring',],
        author='Giampaolo Rodola',
        author_email='psutil@googlegroups.com',
        maintainer='Giampaolo Rodola',
        maintainer_email='g.rodola <at> gmail <dot> com',
        url='http://code.google.com/p/psutil/',
        platforms='Platform Independent',
        license='License :: OSI Approved :: BSD License',
        packages=['psutil'],
        test_suite='test.test_psutil',
        # see: python setup.py register --list-classifiers
        classifiers=[
              'Development Status :: 5 - Production/Stable',
              'Environment :: Console',
              'Operating System :: MacOS :: MacOS X',
              'Operating System :: Microsoft',
              'Operating System :: Microsoft :: Windows :: Windows NT/2000',
              'Operating System :: POSIX',
              'Operating System :: POSIX :: Linux',
              'Operating System :: POSIX :: BSD :: FreeBSD',
              'Operating System :: POSIX :: SunOS/Solaris',
              'Operating System :: OS Independent',
              'Programming Language :: C',
              'Programming Language :: Python',
              'Programming Language :: Python :: 2',
              'Programming Language :: Python :: 2.4',
              'Programming Language :: Python :: 2.5',
              'Programming Language :: Python :: 2.6',
              'Programming Language :: Python :: 2.7',
              'Programming Language :: Python :: 3',
              'Programming Language :: Python :: 3.0',
              'Programming Language :: Python :: 3.1',
              'Programming Language :: Python :: 3.2',
              'Programming Language :: Python :: 3.3',
              'Topic :: System :: Monitoring',
              'Topic :: System :: Networking',
              'Topic :: System :: Networking :: Monitoring',
              'Topic :: System :: Benchmark',
              'Topic :: System :: Hardware',
              'Topic :: System :: Systems Administration',
              'Topic :: Utilities',
              'Topic :: Software Development :: Libraries',
              'Topic :: Software Development :: Libraries :: Python Modules',
              'Intended Audience :: Developers',
              'Intended Audience :: System Administrators',
              'License :: OSI Approved :: BSD License',
              ],
        )
    if extensions is not None:
        setup_args["ext_modules"] = extensions
    setup(**setup_args)

if __name__ == '__main__':
    main()