-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·52 lines (43 loc) · 1.47 KB
/
setup.py
File metadata and controls
executable file
·52 lines (43 loc) · 1.47 KB
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
#!/usr/bin/env python
import os.path
import shlex
import sys
import subprocess
from distutils.core import setup, Extension
PCRE_VERSION = 8.30
def get_pcre_info():
cmd = 'pcre-config --version --prefix'
args = shlex.split(cmd)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
retcode = p.wait()
if retcode != 0:
# pcre-config wrote message to stderr
exit(1)
version = p.stdout.readline()
prefix = p.stdout.readline()
return (version, prefix)
version, prefix = get_pcre_info()
if float(version) < PCRE_VERSION:
print >>sys.stderr, 'pcre is required in version >=', PCRE_VERSION
exit(1)
pcre_include_dir = os.path.join(prefix, 'include')
pcre_library_dir = os.path.join(prefix, 'lib')
setup(name='python-pcre',
version='0.1',
description=('Python binding of PCRE (Perl Compatible Regular '
'Expressions) library that supports JIT compilation of '
'patterns.'),
author='Jakub Matys',
author_email='matys.jakub@gmail.com',
url='https://github.com/jakm/python-pcre',
packages=['pcre'],
package_dir={'': 'src'},
ext_modules=[
Extension('_pcre',
['src/_pcre/pcre_match.c', 'src/_pcre/pcre_module.c',
'src/_pcre/pcre_regex.c'],
include_dirs=[pcre_include_dir],
library_dirs=[pcre_library_dir],
libraries=['pcre'],
extra_compile_args=['-Wall', '-std=gnu99'])]
)