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.
12 from setuptools
import setup
, Extension
14 from distutils
.core
import setup
, Extension
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
)
40 INIT
= os
.path
.abspath(os
.path
.join(os
.path
.dirname(__file__
),
41 'psutil', '__init__.py'))
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
52 raise ValueError("couldn't find version string")
56 def get_description():
57 README
= os
.path
.abspath(os
.path
.join(os
.path
.dirname(__file__
), 'README'))
64 VERSION
= get_version()
68 if os
.name
== 'posix':
69 posix_extension
= Extension('_psutil_posix',
70 sources
= ['psutil/_psutil_posix.c'])
72 if sys
.platform
.startswith("win32"):
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",
89 #extra_compile_args=["/Z7"],
90 #extra_link_args=["/DEBUG"]
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']
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"],
112 elif sys
.platform
.startswith("linux"):
113 extensions
= [Extension('_psutil_linux',
114 sources
=['psutil/_psutil_linux.c'],
118 elif sys
.platform
.lower().startswith('sunos'):
119 extensions
= [Extension('_psutil_sunos',
120 sources
=['psutil/_psutil_sunos.c'],
121 libraries
=['kstat', 'nsl'],
125 sys
.exit('platform %s is not supported' % sys
.platform
)
129 # "python setup.py clean" custom command
130 if len(sys
.argv
) > 1 and sys
.argv
[1] == 'clean':
136 download_url
="http://psutil.googlecode.com/files/psutil-%s.tar.gz" \
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',
152 test_suite
='test.test_psutil',
153 # see: python setup.py register --list-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
195 if __name__
== '__main__':