2012-09-19 22:20:16 +04:00
|
|
|
#!/usr/bin/env python
|
2013-05-10 02:39:30 +04:00
|
|
|
|
2013-08-23 10:36:57 +04:00
|
|
|
# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
|
2012-09-19 22:20:16 +04:00
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2014-12-23 21:45:15 +03:00
|
|
|
"""psutil is a cross-platform library for retrieving information on
|
|
|
|
running processes and system utilization (CPU, memory, disks, network)
|
|
|
|
in Python.
|
|
|
|
"""
|
|
|
|
|
2014-12-24 08:04:19 +03:00
|
|
|
import os
|
2014-12-23 21:45:15 +03:00
|
|
|
import sys
|
2012-09-19 22:20:16 +04:00
|
|
|
try:
|
|
|
|
from setuptools import setup, Extension
|
|
|
|
except ImportError:
|
|
|
|
from distutils.core import setup, Extension
|
|
|
|
|
|
|
|
|
2014-12-23 21:45:15 +03:00
|
|
|
HERE = os.path.abspath(os.path.dirname(__file__))
|
2013-08-23 10:36:57 +04:00
|
|
|
|
|
|
|
|
2012-09-19 22:20:16 +04:00
|
|
|
def get_version():
|
2014-12-23 21:45:15 +03:00
|
|
|
INIT = os.path.join(HERE, 'psutil/__init__.py')
|
2015-08-20 15:03:31 +03:00
|
|
|
with open(INIT, 'r') as f:
|
2012-09-19 22:20:16 +04:00
|
|
|
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")
|
|
|
|
|
2014-12-23 21:45:15 +03:00
|
|
|
|
2012-09-19 22:20:16 +04:00
|
|
|
def get_description():
|
2014-12-23 21:45:15 +03:00
|
|
|
README = os.path.join(HERE, 'README.rst')
|
2015-08-20 15:03:31 +03:00
|
|
|
with open(README, 'r') as f:
|
2012-09-19 22:20:16 +04:00
|
|
|
return f.read()
|
2015-08-20 15:03:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
VERSION = get_version()
|
|
|
|
VERSION_MACRO = ('PSUTIL_VERSION', int(VERSION.replace('.', '')))
|
2012-09-19 22:20:16 +04:00
|
|
|
|
|
|
|
|
|
|
|
# POSIX
|
|
|
|
if os.name == 'posix':
|
2015-08-20 15:03:31 +03:00
|
|
|
libraries = []
|
|
|
|
if sys.platform.startswith("sunos"):
|
|
|
|
libraries.append('socket')
|
|
|
|
|
2014-12-23 21:45:15 +03:00
|
|
|
posix_extension = Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_posix',
|
2014-12-23 21:45:15 +03:00
|
|
|
sources=['psutil/_psutil_posix.c'],
|
2015-08-20 15:03:31 +03:00
|
|
|
libraries=libraries,
|
2014-12-23 21:45:15 +03:00
|
|
|
)
|
2012-09-19 22:20:16 +04:00
|
|
|
# Windows
|
|
|
|
if sys.platform.startswith("win32"):
|
|
|
|
|
|
|
|
def get_winver():
|
|
|
|
maj, min = sys.getwindowsversion()[0:2]
|
|
|
|
return '0x0%s' % ((maj * 100) + min)
|
|
|
|
|
2014-12-23 21:45:15 +03:00
|
|
|
extensions = [Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_windows',
|
2014-12-23 21:45:15 +03:00
|
|
|
sources=[
|
|
|
|
'psutil/_psutil_windows.c',
|
|
|
|
'psutil/_psutil_common.c',
|
|
|
|
'psutil/arch/windows/process_info.c',
|
|
|
|
'psutil/arch/windows/process_handles.c',
|
|
|
|
'psutil/arch/windows/security.c',
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil/arch/windows/inet_ntop.c',
|
2014-12-23 21:45:15 +03:00
|
|
|
],
|
|
|
|
define_macros=[
|
2015-08-20 15:03:31 +03:00
|
|
|
VERSION_MACRO,
|
2014-12-23 21:45:15 +03:00
|
|
|
# be nice to mingw, see:
|
|
|
|
# http://www.mingw.org/wiki/Use_more_recent_defined_functions
|
|
|
|
('_WIN32_WINNT', get_winver()),
|
|
|
|
('_AVAIL_WINVER_', get_winver()),
|
2015-08-20 15:03:31 +03:00
|
|
|
('_CRT_SECURE_NO_WARNINGS', None),
|
2014-12-23 21:45:15 +03:00
|
|
|
# see: https://github.com/giampaolo/psutil/issues/348
|
|
|
|
('PSAPI_VERSION', 1),
|
|
|
|
],
|
|
|
|
libraries=[
|
|
|
|
"psapi", "kernel32", "advapi32", "shell32", "netapi32", "iphlpapi",
|
2015-08-20 15:03:31 +03:00
|
|
|
"wtsapi32", "ws2_32",
|
2014-12-23 21:45:15 +03:00
|
|
|
],
|
|
|
|
# extra_compile_args=["/Z7"],
|
|
|
|
# extra_link_args=["/DEBUG"]
|
|
|
|
)]
|
2012-09-19 22:20:16 +04:00
|
|
|
# OS X
|
|
|
|
elif sys.platform.startswith("darwin"):
|
2014-12-23 21:45:15 +03:00
|
|
|
extensions = [Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_osx',
|
2014-12-23 21:45:15 +03:00
|
|
|
sources=[
|
|
|
|
'psutil/_psutil_osx.c',
|
|
|
|
'psutil/_psutil_common.c',
|
|
|
|
'psutil/arch/osx/process_info.c'
|
|
|
|
],
|
2015-08-20 15:03:31 +03:00
|
|
|
define_macros=[VERSION_MACRO],
|
2014-12-23 21:45:15 +03:00
|
|
|
extra_link_args=[
|
|
|
|
'-framework', 'CoreFoundation', '-framework', 'IOKit'
|
|
|
|
],
|
|
|
|
),
|
|
|
|
posix_extension,
|
|
|
|
]
|
2012-09-19 22:20:16 +04:00
|
|
|
# FreeBSD
|
|
|
|
elif sys.platform.startswith("freebsd"):
|
2014-12-23 21:45:15 +03:00
|
|
|
extensions = [Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_bsd',
|
2014-12-23 21:45:15 +03:00
|
|
|
sources=[
|
|
|
|
'psutil/_psutil_bsd.c',
|
|
|
|
'psutil/_psutil_common.c',
|
|
|
|
'psutil/arch/bsd/process_info.c'
|
|
|
|
],
|
2015-08-20 15:03:31 +03:00
|
|
|
define_macros=[VERSION_MACRO],
|
2014-12-23 21:45:15 +03:00
|
|
|
libraries=["devstat"]),
|
|
|
|
posix_extension,
|
|
|
|
]
|
2012-09-19 22:20:16 +04:00
|
|
|
# Linux
|
|
|
|
elif sys.platform.startswith("linux"):
|
2014-12-23 21:45:15 +03:00
|
|
|
extensions = [Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_linux',
|
|
|
|
sources=['psutil/_psutil_linux.c'],
|
|
|
|
define_macros=[VERSION_MACRO]),
|
2014-12-23 21:45:15 +03:00
|
|
|
posix_extension,
|
|
|
|
]
|
2013-08-23 10:36:57 +04:00
|
|
|
# Solaris
|
|
|
|
elif sys.platform.lower().startswith('sunos'):
|
2014-12-23 21:45:15 +03:00
|
|
|
extensions = [Extension(
|
2015-08-20 15:03:31 +03:00
|
|
|
'psutil._psutil_sunos',
|
2014-12-23 21:45:15 +03:00
|
|
|
sources=['psutil/_psutil_sunos.c'],
|
2015-08-20 15:03:31 +03:00
|
|
|
define_macros=[VERSION_MACRO],
|
|
|
|
libraries=['kstat', 'nsl', 'socket']),
|
2014-12-23 21:45:15 +03:00
|
|
|
posix_extension,
|
|
|
|
]
|
2012-09-19 22:20:16 +04:00
|
|
|
else:
|
|
|
|
sys.exit('platform %s is not supported' % sys.platform)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
setup_args = dict(
|
|
|
|
name='psutil',
|
2015-08-20 15:03:31 +03:00
|
|
|
version=VERSION,
|
2014-12-23 21:45:15 +03:00
|
|
|
description=__doc__.replace('\n', '').strip(),
|
2012-09-19 22:20:16 +04:00
|
|
|
long_description=get_description(),
|
2014-12-23 21:45:15 +03:00
|
|
|
keywords=[
|
2015-08-20 15:03:31 +03:00
|
|
|
'ps', 'top', 'kill', 'free', 'lsof', 'netstat', 'nice', 'tty',
|
|
|
|
'ionice', 'uptime', 'taskmgr', 'process', 'df', 'iotop', 'iostat',
|
|
|
|
'ifconfig', 'taskset', 'who', 'pidof', 'pmap', 'smem', 'pstree',
|
|
|
|
'monitoring', 'ulimit', 'prlimit',
|
2014-12-23 21:45:15 +03:00
|
|
|
],
|
2013-08-23 10:36:57 +04:00
|
|
|
author='Giampaolo Rodola',
|
2014-12-23 21:45:15 +03:00
|
|
|
author_email='g.rodola <at> gmail <dot> com',
|
|
|
|
url='https://github.com/giampaolo/psutil',
|
2012-09-19 22:20:16 +04:00
|
|
|
platforms='Platform Independent',
|
2014-12-23 21:45:15 +03:00
|
|
|
license='BSD',
|
2012-09-19 22:20:16 +04:00
|
|
|
packages=['psutil'],
|
2013-08-23 10:36:57 +04:00
|
|
|
# see: python setup.py register --list-classifiers
|
2012-09-19 22:20:16 +04:00
|
|
|
classifiers=[
|
2014-12-23 21:45:15 +03:00
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
'Environment :: Console',
|
|
|
|
'Environment :: Win32 (MS Windows)',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: Information Technology',
|
|
|
|
'Intended Audience :: System Administrators',
|
|
|
|
'License :: OSI Approved :: BSD License',
|
|
|
|
'Operating System :: MacOS :: MacOS X',
|
|
|
|
'Operating System :: Microsoft :: Windows :: Windows NT/2000',
|
|
|
|
'Operating System :: Microsoft',
|
|
|
|
'Operating System :: OS Independent',
|
|
|
|
'Operating System :: POSIX :: BSD :: FreeBSD',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
|
|
|
'Operating System :: POSIX :: SunOS/Solaris',
|
|
|
|
'Operating System :: POSIX',
|
|
|
|
'Programming Language :: C',
|
|
|
|
'Programming Language :: Python :: 2',
|
|
|
|
'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',
|
|
|
|
'Programming Language :: Python :: 3.4',
|
|
|
|
'Programming Language :: Python :: Implementation :: CPython',
|
|
|
|
'Programming Language :: Python :: Implementation :: PyPy',
|
|
|
|
'Programming Language :: Python',
|
|
|
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
|
|
|
'Topic :: Software Development :: Libraries',
|
|
|
|
'Topic :: System :: Benchmark',
|
|
|
|
'Topic :: System :: Hardware',
|
|
|
|
'Topic :: System :: Monitoring',
|
|
|
|
'Topic :: System :: Networking :: Monitoring',
|
|
|
|
'Topic :: System :: Networking',
|
|
|
|
'Topic :: System :: Systems Administration',
|
|
|
|
'Topic :: Utilities',
|
|
|
|
],
|
|
|
|
)
|
2012-09-19 22:20:16 +04:00
|
|
|
if extensions is not None:
|
|
|
|
setup_args["ext_modules"] = extensions
|
|
|
|
setup(**setup_args)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|