Bumping manifests a=b2g-bump
[gecko.git] / python / psutil / setup.py
blob10f568e7af89152d432ea10b851c56db346a0b84
1 #!/usr/bin/env python
3 # Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 import sys
8 import os
9 import shutil
10 import fnmatch
11 try:
12 from setuptools import setup, Extension
13 except ImportError:
14 from distutils.core import setup, Extension
17 def clean():
18 """'python setup.py clean' custom command."""
19 def rglob(path, pattern):
20 return [os.path.join(dirpath, f)
21 for dirpath, dirnames, files in os.walk(path)
22 for f in fnmatch.filter(files, pattern)]
24 for dirname in ('build', 'dist'):
25 if os.path.isdir(dirname):
26 sys.stdout.write('removing directory: %s\n' % dirname)
27 shutil.rmtree(dirname)
29 for dirpath, dirnames, files in os.walk('.'):
30 if dirpath.endswith(('__pycache__', '.egg-info')):
31 sys.stdout.write('removing directory %s\n' % dirpath)
32 shutil.rmtree(dirpath)
34 for pattern in ['*.py[co]', '*.s[ol]', '*~', '*.orig', '*.rej', '*.swp']:
35 for x in rglob('.', pattern):
36 sys.stdout.write('removing file %s\n' % x)
37 os.remove(x)
39 def get_version():
40 INIT = os.path.abspath(os.path.join(os.path.dirname(__file__),
41 'psutil', '__init__.py'))
42 f = open(INIT, 'r')
43 try:
44 for line in f:
45 if line.startswith('__version__'):
46 ret = eval(line.strip().split(' = ')[1])
47 assert ret.count('.') == 2, ret
48 for num in ret.split('.'):
49 assert num.isdigit(), ret
50 return ret
51 else:
52 raise ValueError("couldn't find version string")
53 finally:
54 f.close()
56 def get_description():
57 README = os.path.abspath(os.path.join(os.path.dirname(__file__), 'README'))
58 f = open(README, 'r')
59 try:
60 return f.read()
61 finally:
62 f.close()
64 VERSION = get_version()
67 # POSIX
68 if os.name == 'posix':
69 posix_extension = Extension('_psutil_posix',
70 sources = ['psutil/_psutil_posix.c'])
71 # Windows
72 if sys.platform.startswith("win32"):
74 def get_winver():
75 maj, min = sys.getwindowsversion()[0:2]
76 return '0x0%s' % ((maj * 100) + min)
78 extensions = [Extension('_psutil_mswindows',
79 sources=['psutil/_psutil_mswindows.c',
80 'psutil/_psutil_common.c',
81 'psutil/arch/mswindows/process_info.c',
82 'psutil/arch/mswindows/process_handles.c',
83 'psutil/arch/mswindows/security.c'],
84 define_macros=[('_WIN32_WINNT', get_winver()),
85 ('_AVAIL_WINVER_', get_winver())],
86 libraries=["psapi", "kernel32", "advapi32",
87 "shell32", "netapi32", "iphlpapi",
88 "wtsapi32"],
89 #extra_compile_args=["/Z7"],
90 #extra_link_args=["/DEBUG"]
92 # OS X
93 elif sys.platform.startswith("darwin"):
94 extensions = [Extension('_psutil_osx',
95 sources = ['psutil/_psutil_osx.c',
96 'psutil/_psutil_common.c',
97 'psutil/arch/osx/process_info.c'],
98 extra_link_args=['-framework', 'CoreFoundation',
99 '-framework', 'IOKit']
101 posix_extension]
102 # FreeBSD
103 elif sys.platform.startswith("freebsd"):
104 extensions = [Extension('_psutil_bsd',
105 sources = ['psutil/_psutil_bsd.c',
106 'psutil/_psutil_common.c',
107 'psutil/arch/bsd/process_info.c'],
108 libraries=["devstat"],
110 posix_extension]
111 # Linux
112 elif sys.platform.startswith("linux"):
113 extensions = [Extension('_psutil_linux',
114 sources=['psutil/_psutil_linux.c'],
116 posix_extension]
117 # Solaris
118 elif sys.platform.lower().startswith('sunos'):
119 extensions = [Extension('_psutil_sunos',
120 sources=['psutil/_psutil_sunos.c'],
121 libraries=['kstat', 'nsl'],
123 posix_extension]
124 else:
125 sys.exit('platform %s is not supported' % sys.platform)
128 def main():
129 # "python setup.py clean" custom command
130 if len(sys.argv) > 1 and sys.argv[1] == 'clean':
131 return clean()
133 setup_args = dict(
134 name='psutil',
135 version=VERSION,
136 download_url="http://psutil.googlecode.com/files/psutil-%s.tar.gz" \
137 % VERSION,
138 description='A process and system utilities module for Python',
139 long_description=get_description(),
140 keywords=['ps', 'top', 'kill', 'free', 'lsof', 'netstat', 'nice',
141 'tty', 'ionice', 'uptime', 'taskmgr', 'process', 'df',
142 'iotop', 'iostat', 'ifconfig', 'taskset', 'who', 'pidof',
143 'pmap', 'smem', 'monitoring',],
144 author='Giampaolo Rodola',
145 author_email='psutil@googlegroups.com',
146 maintainer='Giampaolo Rodola',
147 maintainer_email='g.rodola <at> gmail <dot> com',
148 url='http://code.google.com/p/psutil/',
149 platforms='Platform Independent',
150 license='License :: OSI Approved :: BSD License',
151 packages=['psutil'],
152 test_suite='test.test_psutil',
153 # see: python setup.py register --list-classifiers
154 classifiers=[
155 'Development Status :: 5 - Production/Stable',
156 'Environment :: Console',
157 'Operating System :: MacOS :: MacOS X',
158 'Operating System :: Microsoft',
159 'Operating System :: Microsoft :: Windows :: Windows NT/2000',
160 'Operating System :: POSIX',
161 'Operating System :: POSIX :: Linux',
162 'Operating System :: POSIX :: BSD :: FreeBSD',
163 'Operating System :: POSIX :: SunOS/Solaris',
164 'Operating System :: OS Independent',
165 'Programming Language :: C',
166 'Programming Language :: Python',
167 'Programming Language :: Python :: 2',
168 'Programming Language :: Python :: 2.4',
169 'Programming Language :: Python :: 2.5',
170 'Programming Language :: Python :: 2.6',
171 'Programming Language :: Python :: 2.7',
172 'Programming Language :: Python :: 3',
173 'Programming Language :: Python :: 3.0',
174 'Programming Language :: Python :: 3.1',
175 'Programming Language :: Python :: 3.2',
176 'Programming Language :: Python :: 3.3',
177 'Topic :: System :: Monitoring',
178 'Topic :: System :: Networking',
179 'Topic :: System :: Networking :: Monitoring',
180 'Topic :: System :: Benchmark',
181 'Topic :: System :: Hardware',
182 'Topic :: System :: Systems Administration',
183 'Topic :: Utilities',
184 'Topic :: Software Development :: Libraries',
185 'Topic :: Software Development :: Libraries :: Python Modules',
186 'Intended Audience :: Developers',
187 'Intended Audience :: System Administrators',
188 'License :: OSI Approved :: BSD License',
191 if extensions is not None:
192 setup_args["ext_modules"] = extensions
193 setup(**setup_args)
195 if __name__ == '__main__':
196 main()