File: setup.py

package info (click to toggle)
libxml2 2.4.19-4woody2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 14,936 kB
  • ctags: 5,542
  • sloc: ansic: 74,548; xml: 20,808; sh: 6,898; python: 2,869; makefile: 785
file content (120 lines) | stat: -rw-r--r-- 3,178 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/python -u
#
# Setup script for libxml2 and libxslt if found
#
import sys, os
from distutils.core import setup, Extension


def missing(file):
    if os.access(file, os.R_OK) == 0:
        return 1
    return 0

xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
             "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
	     "xmlgenerator.py", "README", "TODO"]

xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml",
             "libxslt.c", "libxsl.py", "libxslt_wrap.h",
	     "xsltgenerator.py"]

if missing("libxml2-py.c") or missing("libxml2.py"):
    try:
	try:
	    import xmlgenerator
	except:
	    import generator
    except:
	print "failed to find and generate stubs for libxml2, aborting ..."
	print sys.exc_type, sys.exc_value
	sys.exit(1)

    head = open("libxml.py", "r")
    generated = open("libxml2class.py", "r")
    result = open("libxml2.py", "w")
    for line in head.readlines():
	result.write(line)
    for line in generated.readlines():
	result.write(line)
    head.close()
    generated.close()
    result.close()

with_xslt=0
if missing("libxslt-py.c") or missing("libxslt.py"):
    if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
        print "libxslt stub generator not found, libxslt not built"
    else:
	try:
	    import xsltgenerator
	except:
	    print "failed to generate stubs for libxslt, aborting ..."
	    print sys.exc_type, sys.exc_value
	else:
	    head = open("libxsl.py", "r")
	    generated = open("libxsltclass.py", "r")
	    result = open("libxslt.py", "w")
	    for line in head.readlines():
		result.write(line)
	    for line in generated.readlines():
		result.write(line)
	    head.close()
	    generated.close()
	    result.close()
	    with_xslt=1
else:
    with_xslt=1


descr = "libxml2 package"
modules = [ 'libxml2' ]
c_files = ['libxml2-py.c', 'libxml.c', 'types.c' ]
includes= ["/usr/include/libxml2"]
libs    = ["xml2", "m", "z"]
macros  = []
if with_xslt == 1:
    descr = "libxml2 and libxslt package"
    #
    # We are gonna build 2 identical shared libs with merge initializing
    # both libxml2mod and libxsltmod
    #
    c_files = c_files + ['libxslt-py.c', 'libxslt.c']
    libs.insert(0, 'xslt')
    includes.append("/usr/include/libxslt")
    modules.append('libxslt')
    macros.append(('MERGED_MODULES', '1'))


extens=[Extension('libxml2mod', c_files, include_dirs=includes,
                  libraries=libs, define_macros=macros)] 
if with_xslt == 1:
    extens.append(Extension('libxsltmod', c_files, include_dirs=includes,
			    libraries=libs))

if missing("MANIFEST"):
    global xml_files

    manifest = open("MANIFEST", "w")
    manifest.write("setup.py\n")
    for file in xml_files:
        manifest.write(file + "\n")
    if with_xslt == 1:
	for file in xslt_files:
	    manifest.write(file + "\n")
    manifest.close()

setup (name = "libxml2-python",
       version = "2.4.19",
       description = descr,
       author = "Daniel Veillard",
       author_email = "veillard@redhat.com",
       url = "http://xmlsoft.org/python.html",
       licence="MIT Licence",

       py_modules=modules,
       ext_modules=extens,
       )

sys.exit(0)