forked from andreikop/qutepart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
executable file
·108 lines (84 loc) · 3.77 KB
/
setup.py
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
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python
import sys
import os
import platform
from distutils.core import setup, Extension
import distutils.ccompiler
import distutils.sysconfig
import qutepart
def parse_arg_list(param_start):
"""Exctract values like --libdir=bla/bla/bla
param_start must be '--libdir='
"""
values = [arg[len(param_start):] \
for arg in sys.argv \
if arg.startswith(param_start)]
# remove recognized arguments from the sys.argv
otherArgs = [arg \
for arg in sys.argv \
if not arg.startswith(param_start)]
sys.argv = otherArgs
return values
packages=['qutepart', 'qutepart/syntax', 'qutepart/indenter']
package_data={'qutepart' : ['icons/*.png'],
'qutepart/syntax' : ['data/xml/*.xml',
'data/syntax_db.json']
}
include_dirs = parse_arg_list('--include-dir=')
if not include_dirs:
include_dirs = ['/usr/include', '/usr/local/include', '/opt/local/include']
library_dirs = parse_arg_list('--lib-dir=')
if not library_dirs:
library_dirs = ['/usr/lib', '/usr/local/lib', '/opt/local/lib']
macros = []
if platform.system() == 'Windows':
macros.append(('HAVE_PCRE_CONFIG_H', None))
extension = Extension('qutepart.syntax.cParser',
sources = ['qutepart/syntax/cParser.c'],
libraries = ['pcre'],
include_dirs=include_dirs,
library_dirs=library_dirs,
define_macros = macros)
def _checkDependencies():
compiler = distutils.ccompiler.new_compiler()
"""check if function without parameters from stdlib can be called
There should be better way to check, if C compiler is installed
"""
if not compiler.has_function('rand', includes = ['stdlib.h']):
print "It seems like C compiler is not installed or not operable."
return False
if not compiler.has_function('rand',
includes = ['stdlib.h', 'Python.h'],
include_dirs=[distutils.sysconfig.get_python_inc()],
library_dirs=[os.path.join(os.path.dirname(sys.executable), 'libs')]):
print "Failed to find Python headers."
print "Try to install python-dev package"
print "If not standard directories are used, pass parameters"
print "\tpython setup.py install --lib-dir=/my/local/lib --include-dir=/my/local/include"
print "--lib-dir= and --include-dir= may be used multiple times"
return False
if not compiler.has_function('pcre_version',
includes = ['pcre.h'],
libraries = ['pcre'],
include_dirs=include_dirs,
library_dirs=library_dirs):
print "Failed to find pcre library."
print "Try to install libpcre{version}-dev package, or go to http://pcre.org"
print "If not standard directories are used, pass parameters:"
print "\tpython setup.py install --lib-dir=/my/local/lib --include-dir=/my/local/include"
print "--lib-dir= and --include-dir= may be used multiple times"
return False
return True
if 'install' in sys.argv or 'build' in sys.argv or 'build_ext' in sys.argv:
if not '--force' in sys.argv and not '--help' in sys.argv:
if not _checkDependencies():
sys.exit(-1)
setup (name='qutepart',
version='%s.%s.%s' % qutepart.VERSION,
description='Code editor component for PyQt and PySide',
author='Andrei Kopats',
author_email='[email protected]',
url='https://github.com/hlamer/qutepart',
packages = packages,
package_data = package_data,
ext_modules = [extension])