This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
forked from rtyler/py-yajl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
85 lines (69 loc) · 2.66 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
#!/usr/bin/env python
import os
import subprocess
import sys
USE_SETUPTOOLS = False
try:
from setuptools import setup, Extension
USE_SETUPTOOLS = True
except ImportError:
from distutils.core import setup, Extension
version = '0.3.6'
if os.path.exists('.git'):
try:
commit = subprocess.Popen(['git', 'log', '--max-count=1', '--format=%h'], stdout=subprocess.PIPE).communicate()[0]
# OIL PATCH
# use + instead of - to remove setuptools warning about PEP 440 version identifiers
version = '%s+%s' % (version, commit.strip())
except:
pass
base_modules = [
Extension('yajl', [
'yajl.c',
'encoder.c',
'decoder.c',
'yajl/src/yajl_alloc.c',
'yajl/src/yajl_buf.c',
'yajl/src/yajl.c',
'yajl/src/yajl_encode.c',
'yajl/src/yajl_gen.c',
'yajl/src/yajl_lex.c',
'yajl/src/yajl_parser.c',
],
include_dirs=('.', 'includes/', 'yajl/src'),
extra_compile_args=['-Wall', '-DMOD_VERSION="%s"' % version],
language='c'),
]
packages = ('yajl',)
setup_kwargs = dict(
name = 'yajl',
description = '''A CPython module for Yet-Another-Json-Library''',
version = version,
author = 'R. Tyler Ballance',
author_email = '[email protected]',
url = 'http://rtyler.github.com/py-yajl',
long_description='''The `yajl` module provides a Python binding to the Yajl library originally written by `Lloyd Hilaiel <http://github.com/lloyd>`_.
Mailing List
==============
You can discuss the C library **Yajl** or py-yajl on the Yajl mailing list,
simply send your email to [email protected]
''',
ext_modules=base_modules,
)
if USE_SETUPTOOLS:
setup_kwargs.update({'test_suite' : 'tests.unit'})
if not os.listdir('yajl'):
# Submodule hasn't been created, let's inform the user
print('>>> It looks like the `yajl` submodule hasn\'t been initialized')
print('>>> I\'ll try to do that, but if I fail, you can run:')
print('>>> `git submodule update --init`')
subprocess.call(['git', 'submodule', 'update', '--init'])
subprocess.call(['git', 'submodule', 'update',])
if not os.path.exists('includes'):
# Our symlink into the yajl directory isn't there, let's fixulate that
os.mkdir('includes')
if not os.path.exists(os.path.join('includes', 'yajl')):
print('>>> Creating a symlink for compilationg: includes/yajl -> yajl/src/api')
# Now that we have a directory, we need a symlink
os.symlink(os.path.join('..', 'yajl', 'src', 'api'), os.path.join('includes', 'yajl'))
setup(**setup_kwargs)