xref: /freebsd/contrib/libucl/python/setup.py (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1try:
2    from setuptools import setup, Extension
3    # setuptools doesn't support template param for MANIFEST.in
4    from setuptools.command.egg_info import manifest_maker
5    manifest_maker.template = 'python/MANIFEST.in'
6except ImportError:
7    from distutils.core import setup, Extension
8
9import os
10import sys
11
12LIB_ROOT = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir))
13if os.getcwd() != LIB_ROOT:
14    os.chdir(LIB_ROOT)
15if LIB_ROOT not in sys.path:
16    sys.path.append(LIB_ROOT)
17
18tests_require = []
19
20if sys.version < '2.7':
21    tests_require.append('unittest2')
22
23uclmodule = Extension(
24    'ucl',
25    libraries=['ucl', 'curl'],
26    sources=['python/src/uclmodule.c'],
27    include_dirs=['include'],
28    language='c',
29)
30
31ucl_lib = {
32    'sources': ['src/' + fn for fn in os.listdir('src') if fn.endswith('.c')],
33    'include_dirs': ['include', 'src', 'uthash', 'klib'],
34    'macros': [('CURL_FOUND', '1')],
35}
36
37# sdist setup() will pull in the *.c files automatically, but not headers
38# MANIFEST.in will include the headers for sdist only
39template = 'python/MANIFEST.in'
40
41# distutils assume setup.py is in the root of the project
42# we need to include C source from the parent so trick it
43in_ucl_root = 'setup.py' in os.listdir('python')
44if in_ucl_root:
45    os.link('python/setup.py', 'setup.py')
46
47setup(
48    name = 'ucl',
49    version = '0.8.1',
50    description = 'ucl parser and emitter',
51    ext_modules = [uclmodule],
52    template=template, # no longer supported with setuptools but doesn't hurt
53    libraries = [('ucl', ucl_lib)],
54    test_suite = 'tests',
55    tests_require = tests_require,
56    author = "Eitan Adler, Denis Volpato Martins",
57    author_email = "lists@eitanadler.com",
58    url = "https://github.com/vstakhov/libucl/",
59    license = "MIT",
60    classifiers = [
61        "Development Status :: 3 - Alpha",
62        "Intended Audience :: Developers",
63        "License :: DFSG approved",
64        "License :: OSI Approved :: MIT License",
65        "Programming Language :: C",
66        "Programming Language :: Python :: 2",
67        "Programming Language :: Python :: 3",
68        "Programming Language :: Python :: Implementation :: CPython",
69        "Topic :: Software Development :: Libraries",
70    ]
71)
72
73# clean up the trick after the build
74if in_ucl_root:
75    os.unlink("setup.py")
76