OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # $Id: setup.py 748 2010-10-29 12:51:58Z g.rodola $ | 3 # $Id: setup.py 1142 2011-10-05 18:45:49Z g.rodola $ |
4 # | 4 # |
| 5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. |
| 6 # Use of this source code is governed by a BSD-style license that can be |
| 7 # found in the LICENSE file. |
5 | 8 |
6 import sys | 9 import sys |
7 import os | 10 import os |
8 import shutil | 11 try: |
9 from distutils.core import setup, Extension | 12 from setuptools import setup, Extension |
| 13 except ImportError: |
| 14 from distutils.core import setup, Extension |
| 15 |
| 16 __ver__ = "0.3.1" |
10 | 17 |
11 # Hack for Python 3 to tell distutils to run 2to3 against the files | 18 # Hack for Python 3 to tell distutils to run 2to3 against the files |
12 # copied in the build directory before installing. | 19 # copied in the build directory before installing. |
13 # Reference: http://osdir.com/ml/python.python-3000.cvs/2008-03/msg00127.html | 20 # Reference: http://docs.python.org/dev/howto/pyporting.html#during-installation |
14 try: | 21 try: |
15 from distutils.command.build_py import build_py_2to3 as build_py | 22 from distutils.command.build_py import build_py_2to3 as build_py |
16 except ImportError: | 23 except ImportError: |
17 from distutils.command.build_py import build_py | 24 from distutils.command.build_py import build_py |
18 | 25 |
19 | 26 |
| 27 if os.name == 'posix': |
| 28 posix_extension = Extension('_psutil_posix', |
| 29 sources = ['psutil/_psutil_posix.c']) |
| 30 |
| 31 |
20 # Windows | 32 # Windows |
21 if sys.platform.lower().startswith("win"): | 33 if sys.platform.lower().startswith("win"): |
22 | 34 |
23 def get_winver(): | 35 def get_winver(): |
24 maj,min = sys.getwindowsversion()[0:2] | 36 maj,min = sys.getwindowsversion()[0:2] |
25 return '0x0%s' % ((maj * 100) + min) | 37 return '0x0%s' % ((maj * 100) + min) |
26 | 38 |
27 extensions = Extension('_psutil_mswindows', | 39 extensions = [Extension('_psutil_mswindows', |
28 sources=['psutil/_psutil_mswindows.c', | 40 sources=['psutil/_psutil_mswindows.c', |
29 'psutil/arch/mswindows/process_info.c', | 41 'psutil/_psutil_common.c', |
30 'psutil/arch/mswindows/process_handles.c', | 42 'psutil/arch/mswindows/process_info.c', |
31 'psutil/arch/mswindows/security.c'], | 43 'psutil/arch/mswindows/process_handles.c', |
32 define_macros=[('_WIN32_WINNT', get_winver()), | 44 'psutil/arch/mswindows/security.c'], |
33 ('_AVAIL_WINVER_', get_winver())], | 45 define_macros=[('_WIN32_WINNT', get_winver()), |
34 libraries=["psapi", "kernel32", "advapi32", "shell32"
, | 46 ('_AVAIL_WINVER_', get_winver())], |
35 "netapi32"] | 47 libraries=["psapi", "kernel32", "advapi32", "shell32
", |
36 ) | 48 "netapi32"] |
| 49 )] |
37 # OS X | 50 # OS X |
38 elif sys.platform.lower().startswith("darwin"): | 51 elif sys.platform.lower().startswith("darwin"): |
39 extensions = Extension('_psutil_osx', | 52 extensions = [Extension('_psutil_osx', |
40 sources = ['psutil/_psutil_osx.c', | 53 sources = ['psutil/_psutil_osx.c', |
41 'psutil/arch/osx/process_info.c'] | 54 'psutil/_psutil_common.c', |
42 ) | 55 'psutil/arch/osx/process_info.c'], |
| 56 extra_link_args=['-framework', 'CoreFoundation', '-f
ramework', 'IOKit'] |
| 57 ), |
| 58 posix_extension] |
43 # FreeBSD | 59 # FreeBSD |
44 elif sys.platform.lower().startswith("freebsd"): | 60 elif sys.platform.lower().startswith("freebsd"): |
45 extensions = Extension('_psutil_bsd', | 61 extensions = [Extension('_psutil_bsd', |
46 sources = ['psutil/_psutil_bsd.c', | 62 sources = ['psutil/_psutil_bsd.c', |
47 'psutil/arch/bsd/process_info.c'] | 63 'psutil/_psutil_common.c', |
48 ) | 64 'psutil/arch/bsd/process_info.c'] |
49 # Others | 65 ), |
| 66 posix_extension] |
| 67 # Linux |
50 elif sys.platform.lower().startswith("linux"): | 68 elif sys.platform.lower().startswith("linux"): |
51 extensions = None | 69 extensions = [Extension('_psutil_linux', |
| 70 sources=['psutil/_psutil_linux.c'], |
| 71 ), |
| 72 posix_extension] |
| 73 |
52 else: | 74 else: |
53 raise NotImplementedError('platform %s is not supported' % sys.platform) | 75 raise NotImplementedError('platform %s is not supported' % sys.platform) |
54 | 76 |
55 | 77 |
56 def main(): | 78 def main(): |
57 setup_args = dict( | 79 setup_args = dict( |
58 name='psutil', | 80 name='psutil', |
59 version="0.2.0", | 81 version=__ver__, |
| 82 download_url="http://psutil.googlecode.com/files/psutil-%s.tar.gz" % __v
er__, |
60 description='A process utilities module for Python', | 83 description='A process utilities module for Python', |
61 long_description=""" | 84 long_description="""\ |
62 psutil is a module providing convenience functions for managing processes in a | 85 psutil is a module providing convenience functions for monitoring |
63 portable way by using Python.""", | 86 system and processes in a portable way by using Python.""", |
64 keywords=['psutil', 'ps', 'top', 'process', 'utility'], | 87 keywords=['ps', 'top', 'kill', 'free', 'lsof', 'netstat', 'nice', |
65 author='Giampaolo Rodola, Dave Daeschler, Jay Loden', | 88 'tty', 'ionice', 'uptime', 'taskmgr', 'process', 'df', |
66 author_email='psutil-dev@googlegroups.com', | 89 'monitoring'], |
| 90 author='Giampaolo Rodola, Jay Loden', |
| 91 author_email='psutil@googlegroups.com', |
67 url='http://code.google.com/p/psutil/', | 92 url='http://code.google.com/p/psutil/', |
68 platforms='Platform Independent', | 93 platforms='Platform Independent', |
69 license='License :: OSI Approved :: BSD License', | 94 license='License :: OSI Approved :: BSD License', |
70 packages=['psutil'], | 95 packages=['psutil'], |
71 cmdclass={'build_py':build_py}, # Python 3.X | 96 cmdclass={'build_py':build_py}, # Python 3.X |
72 classifiers=[ | 97 classifiers=[ |
73 'Development Status :: 5 - Production/Stable', | 98 'Development Status :: 5 - Production/Stable', |
74 'Environment :: Console', | 99 'Environment :: Console', |
75 'Operating System :: MacOS :: MacOS X', | 100 'Operating System :: MacOS :: MacOS X', |
76 'Operating System :: Microsoft :: Windows :: Windows NT/2000', | 101 'Operating System :: Microsoft :: Windows :: Windows NT/2000', |
(...skipping 16 matching lines...) Expand all Loading... |
93 'Topic :: System :: Benchmark', | 118 'Topic :: System :: Benchmark', |
94 'Topic :: System :: Systems Administration', | 119 'Topic :: System :: Systems Administration', |
95 'Topic :: Utilities', | 120 'Topic :: Utilities', |
96 'Topic :: Software Development :: Libraries :: Python Modules', | 121 'Topic :: Software Development :: Libraries :: Python Modules', |
97 'Intended Audience :: Developers', | 122 'Intended Audience :: Developers', |
98 'Intended Audience :: System Administrators', | 123 'Intended Audience :: System Administrators', |
99 'License :: OSI Approved :: MIT License', | 124 'License :: OSI Approved :: MIT License', |
100 ], | 125 ], |
101 ) | 126 ) |
102 if extensions is not None: | 127 if extensions is not None: |
103 setup_args["ext_modules"] = [extensions] | 128 setup_args["ext_modules"] = extensions |
104 | 129 |
105 setup(**setup_args) | 130 setup(**setup_args) |
106 | 131 |
107 | 132 |
108 if __name__ == '__main__': | 133 if __name__ == '__main__': |
109 main() | 134 main() |
110 | 135 |
OLD | NEW |