File: setup.py

package info (click to toggle)
python-setproctitle 1.0.1-1
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 124 kB
  • ctags: 75
  • sloc: ansic: 363; python: 218; makefile: 23
file content (96 lines) | stat: -rw-r--r-- 2,890 bytes parent folder | download
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
#!/usr/bin/env python
"""
setproctitle setup script.

Copyright (c) 2009-2010 Daniele Varrazzo <daniele.varrazzo@gmail.com>
"""

VERSION = '1.0.1'

import os
import re
import sys
from distutils.core import setup, Extension

define_macros={}

define_macros['SPT_VERSION'] = VERSION

if sys.platform == 'linux2':
    try:
        linux_version = map(int, 
            re.search("[.0-9]+", os.popen("uname -r").read())
                .group().split(".")[:3])
    except:
        pass
    else:
        if linux_version >= [2, 6, 9]:
            define_macros['HAVE_SYS_PRCTL_H'] = 1

elif sys.platform == 'darwin':
    # __darwin__ symbol is not defined; __APPLE__ is instead.
    define_macros['__darwin__'] = 1

elif 'bsd' in sys.platform: # OMG, how many of them are?
    # Old BSD versions don't have setproctitle
    # TODO: not tested on an "old BSD"
    if 0 == os.spawnlp(os.P_WAIT, 'grep',
            'grep', '-q', 'setproctitle', '/usr/include/unistd.h'):
        define_macros['HAVE_SETPROCTITLE'] = 1
    else:
        define_macros['HAVE_PS_STRING'] = 1

# NOTE: the library may work on HP-UX using pstat
# thus setting define_macros['HAVE_SYS_PSTAT_H']
# see http://www.noc.utoronto.ca/~mikep/unix/HPTRICKS
# But I have none handy to test with.

mod_spt = Extension('setproctitle',
    define_macros=define_macros.items(),
    sources = [
        'src/setproctitle.c',
        'src/spt_status.c',
        'src/strlcpy.c', # TODO: not needed on some platform
        ])

# patch distutils if it can't cope with the "classifiers" or
# "download_url" keywords
if sys.version < '2.2.3':
    from distutils.dist import DistributionMetadata
    DistributionMetadata.classifiers = None
    DistributionMetadata.download_url = None

# Try to include the long description in the setup
kwargs = {}
try: 
    kwargs['long_description'] = (
        open('README').read()
        + '\n'
        +open('HISTORY').read())
except: 
    pass

setup(
    name = 'setproctitle',
    description = 'Allow customization of the process title.',
    version = VERSION,
    author = 'Daniele Varrazzo',
    author_email = 'daniele.varrazzo@gmail.com',
    url = 'http://code.google.com/p/py-setproctitle/',
    download_url = 'http://pypi.python.org/pypi/setproctitle/',
    license = 'BSD',
    platforms = ['GNU/Linux', 'BSD', 'MacOS X', 'Windows'],
    classifiers = filter(None, map(str.strip, """
        Development Status :: 5 - Production/Stable
        Intended Audience :: Developers
        License :: OSI Approved :: BSD License
        Programming Language :: C
        Programming Language :: Python
        Operating System :: POSIX :: Linux
        Operating System :: POSIX :: BSD
        Operating System :: MacOS :: MacOS X
        Operating System :: Microsoft :: Windows
        Topic :: Software Development
        """.splitlines())),
    ext_modules = [mod_spt],
    **kwargs)