Commit 6b5336b2 authored by YunQiang Su's avatar YunQiang Su

add python3 support

parent 0c27a78a
......@@ -7,6 +7,8 @@ Standards-Version: 3.9.8
Build-Depends: debhelper (>= 9), dh-autoreconf, autotools-dev, pkg-config,
libpython-all-dev, libpython-all-dbg,
python-all-dev:any (>= 2.7.5-5~), python-all-dbg:any,
libpython3-all-dev, libpython3-all-dbg,
python3-all-dev:any (>= 3.5), python3-all-dbg:any,
zlib1g-dev | libz-dev, liblzma-dev, libicu-dev
Homepage: http://xmlsoft.org/
Vcs-Git: git://anonscm.debian.org/debian-xml-sgml/libxml2.git
......@@ -145,3 +147,36 @@ Description: Python bindings for the GNOME XML library (debug extension)
.
This package contains the files needed to use the GNOME XML library
in Python programs for use with the Python debug interpreter.
Package: python3-libxml2
Architecture: any
Section: python
Provides: ${python3:Provides}
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}
Description: Python3 bindings for the GNOME XML library
XML is a metalanguage to let you design your own markup language.
A regular markup language defines a way to describe information in
a certain class of documents (eg HTML). XML lets you define your
own customized markup languages for many classes of document. It
can do this because it's written in SGML, the international standard
metalanguage for markup languages.
.
This package contains the files needed to use the GNOME XML library
in Python3 programs.
Package: python3-libxml2-dbg
Architecture: any
Section: debug
Priority: extra
Provides: ${python3:Provides}
Depends: python3-dbg, python3-libxml2 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
Description: Python3 bindings for the GNOME XML library (debug extension)
XML is a metalanguage to let you design your own markup language.
A regular markup language defines a way to describe information in
a certain class of documents (eg HTML). XML lets you define your
own customized markup languages for many classes of document. It
can do this because it's written in SGML, the international standard
metalanguage for markup languages.
.
This package contains the files needed to use the GNOME XML library
in Python3 programs for use with the Python3 debug interpreter.
usr/lib/python*/*-packages/*.so
usr/lib/python2*/*-packages/*.so
usr/lib/python*/*-packages/*.py*
usr/lib/python*/*-packages/*.so
usr/lib/python2*/*-packages/*.py*
usr/lib/python2*/*-packages/*.so
usr/lib/python3*/*-packages/*.so
python3-libxml2-dbg: hardening-no-fortify-functions
usr/lib/python3*/*-packages/*.py*
usr/lib/python3*/*-packages/*.so
......@@ -3,8 +3,10 @@ export DH_VERBOSE=1
# The versions of python currently supported
PYVERS=$(shell pyversions -s)
PY3VERS=$(shell py3versions -s)
# The current default version of python
PYVER=$(shell pyversions -d)
PY3VER=$(shell py3versions -d)
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
......@@ -15,7 +17,7 @@ CFLAGS = `dpkg-buildflags --get CFLAGS` -Wall -O3
LDFLAGS = `dpkg-buildflags --get LDFLAGS` -Wl,--as-needed
CPPFLAGS = `dpkg-buildflags --get CPPFLAGS`
TARGETS := main $(PYVERS) $(PYVERS:%=%-dbg)
TARGETS := main $(PYVERS) $(PYVERS:%=%-dbg) $(PY3VERS) $(PY3VERS:%=%-dbg)
WITH_UDEB := $(shell dpkg-vendor --derives-from Ubuntu && echo yes)
......@@ -28,7 +30,7 @@ export DH_OPTIONS = -Nlibxml2-udeb
endif
ifeq ($(DEB_BUILD_PROFILE),stage1)
DH_OPTIONS += -Npython-libxml2 -Npython-libxml2-dbg
DH_OPTIONS += -Npython-libxml2 -Npython-libxml2-dbg -Npython3-libxml2 -Npython3-libxml2-dbg
export DH_OPTIONS
endif
......@@ -40,26 +42,26 @@ debian/autoreconf.after:
dh_autoreconf
doconfigure-%: debian/autoreconf.after
dh_auto_configure --builddirectory=builddir/$* -- $(CONFIGURE_FLAGS)
dh_auto_configure --builddirectory=builddir/$(*) -- $(CONFIGURE_FLAGS)
doconfigure-main: CONFIGURE_FLAGS += --without-python --with-icu
doconfigure-python%: CONFIGURE_FLAGS += --with-python=/usr/bin/$*
doconfigure-python%: CONFIGURE_FLAGS += --with-python=/usr/bin/$(*)
#doconfigure-udeb: CONFIGURE_FLAGS += --without-history --with-minimum --with-tree --with-output
doconfigure-udeb: CONFIGURE_FLAGS += --without-history --with-tree --with-output --without-python --without-icu
dobuild-%: BUILD_DIR=builddir/$*
dobuild-%: BUILD_DIR=builddir/$(*)
dobuild-%: doconfigure-%
$(if $(filter $(BUILD_DIR),builddir/$*),,[ -d $(BUILD_DIR) ] || mv builddir/$*/python $(BUILD_DIR))
$(if $(filter $(BUILD_DIR),builddir/$(*)),,[ -d $(BUILD_DIR) ] || mv builddir/$(*)/python $(BUILD_DIR))
dh_auto_build --builddirectory=$(BUILD_DIR) -- $(BUILD_FLAGS)
dobuild-python%: BUILD_DIR=builddir/main/$*
dobuild-python%: BUILD_FLAGS = libxml2mod_la_LIBADD='$$(mylibs)' \
PYTHON_INCLUDES="$(shell $(DEB_HOST_GNU_TYPE)-python-config --includes)" \
PYTHON_LIBS="$(shell $(DEB_HOST_GNU_TYPE)-python-config --ldflags)"
dobuild-python%-dbg: BUILD_FLAGS += PYTHON_INCLUDES="$(shell $(DEB_HOST_GNU_TYPE)-python-dbg-config --includes)" \
PYTHON_LIBS="$(shell $(DEB_HOST_GNU_TYPE)-python-dbg-config --ldflags)" \
CFLAGS="$(CFLAGS) -Wall -g -O0" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS) \
-L$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)"
dobuild-python%: BUILD_DIR=builddir/main/$(*)
dobuild-python%: BUILD_FLAGS=libxml2mod_la_LIBADD='$$(mylibs)' \
PYTHON_INCLUDES='$(shell $(DEB_HOST_GNU_TYPE)-$(*)-config --includes)' \
PYTHON_LIBS='$(shell $(DEB_HOST_GNU_TYPE)-$(*)-config --ldflags)'
dobuild-python%-dbg: BUILD_FLAGS+=PYTHON_INCLUDES='$(shell $(DEB_HOST_GNU_TYPE)-$(*)-config --includes)' \
PYTHON_LIBS='$(shell $(DEB_HOST_GNU_TYPE)-$(*)-config --ldflags)' \
CFLAGS='$(CFLAGS) -Wall -g -O0' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS) \
-L$(CURDIR)/debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)'
#override_dh_auto_build: $(TARGETS:%=dobuild-%)
build-arch: $(TARGETS:%=dobuild-%)
......@@ -98,11 +100,11 @@ override_dh_auto_install-indep:
doc/tutorial debian/tmp/usr/share/doc/libxml2-doc
doinstall-python%-dbg:
$(MAKE) -C builddir/main/python$*-dbg DESTDIR=$(CURDIR)/debian/tmp-dbg install-pythonLTLIBRARIES
prename -vf 's/(?<!_d)\.so$$/_d.so/' debian/tmp-dbg/usr/lib/python$*/*-packages/*.so
$(MAKE) -C builddir/main/python$(*)-dbg DESTDIR=$(CURDIR)/debian/tmp-dbg install-pythonLTLIBRARIES
prename -vf 's/(?<!_d)\.so$$/_d.so/' debian/tmp-dbg/usr/lib/python$(*)/*-packages/*.so
doinstall-python%:
dh_auto_install --builddirectory=builddir/main/python$*
dh_auto_install --builddirectory=builddir/main/python$(*)
doinstall-udeb:
dh_auto_install --builddirectory=builddir/udeb --destdir=debian/tmp-udeb
......@@ -110,6 +112,7 @@ doinstall-udeb:
override_dh_installdocs:
dh_installdocs -A AUTHORS TODO README NEWS
dh_installdocs -ppython-libxml2 python/TODO
dh_installdocs -ppython3-libxml2 python/TODO
override_dh_compress:
dh_compress -Xexamples/ -Xtutorial/ -Xhtml/ -X.html
......@@ -119,18 +122,20 @@ override_dh_installchangelogs:
dh_installchangelogs -Nlibxml2 -XChangeLog
override_dh_install-arch:
dh_install -Npython-libxml2-dbg -Nlibxml2-udeb
dh_install -Npython-libxml2-dbg -Npython3-libxml2-dbg -Nlibxml2-udeb
ifneq ($(DEB_BUILD_PROFILE),stage1)
dh_install -ppython-libxml2-dbg --sourcedir=debian/tmp-dbg
dh_install -ppython3-libxml2-dbg --sourcedir=debian/tmp-dbg
endif
dh_install -plibxml2-udeb --sourcedir=debian/tmp-udeb
sed -i -e 's,/lib/$(DEB_HOST_MULTIARCH),/lib,' debian/libxml2-dev/usr/bin/xml2-config
override_dh_strip:
dh_strip -a --dbg-package=libxml2-dbg -Nlibxml2-udeb -Nlibxml2-utils -Nlibxml2-utils-dbg -Npython-libxml2 -Npython-libxml2-dbg
dh_strip -a --dbg-package=libxml2-dbg -Nlibxml2-udeb -Nlibxml2-utils -Nlibxml2-utils-dbg -Npython-libxml2 -Npython-libxml2-dbg -Npython3-libxml2 -Npython3-libxml2-dbg
dh_strip -plibxml2-utils --dbg-package=libxml2-utils-dbg
ifneq ($(DEB_BUILD_PROFILE),stage1)
dh_strip -ppython-libxml2 --dbg-package=python-libxml2-dbg
dh_strip -ppython3-libxml2 --dbg-package=python3-libxml2-dbg
endif
$(foreach python, $(filter-out $(PYVER), $(PYVERS)),\
cd $(CURDIR)/debian/python-libxml2/usr/lib/pyshared; \
......@@ -138,7 +143,13 @@ endif
rm -f $(python)/libxml2mod.so; \
ln -s ../$(PYVER)/libxml2mod.so $(python)/libxml2mod.so; \
fi;)
dh_strip
$(foreach python3, $(filter-out $(PY3VER), $(PY3VERS)),\
cd $(CURDIR)/debian/python3-libxml2/usr/lib/pyshared; \
if diff $(python3)/libxml2mod.so $(PYVER)/libxml2mod.so > /dev/null 2>&1; then \
rm -f $(python3)/libxml2mod.so; \
ln -s ../$(PY3VER)/libxml2mod.so $(python3)/libxml2mod.so; \
fi;)
dh_strip -Npython-libxml2-dbg -Npython3-libxml2-dbg
override_dh_makeshlibs:
dh_makeshlibs -a $(if $(WITH_UDEB),--add-udeb=libxml2-udeb )-V 'libxml2 (>= 2.7.4)' -- -c4
......@@ -150,5 +161,5 @@ override_dh_gencontrol:
ifeq ($(DEB_BUILD_PROFILE),stage1)
dh $@ --with autoreconf
else
dh $@ --parallel --with autoreconf,python2
dh $@ --parallel --with autoreconf,python2,python3
endif
Tests: build python
Depends: libxml2-dev, python-libxml2, build-essential, pkg-config
Depends: libxml2-dev, python-libxml2, python-libxml2, build-essential, pkg-config
#!/bin/sh
python2 <<EOF
import libxml2
import sys
doc = libxml2.parseDoc(
"""<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
<!ATTLIST test abc:attr CDATA #FIXED "def" >
]>
<test />
""")
elem = doc.getRootElement()
attr = elem.hasNsProp('attr', 'http://abc.org')
if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
print("Failed to find defaulted attribute abc:attr")
sys.exit(1)
doc.freeDoc()
EOF
#!/bin/sh
python3 <<EOF
import libxml2
import sys
doc = libxml2.parseDoc(
"""<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
<!ATTLIST test abc:attr CDATA #FIXED "def" >
]>
<test />
""")
elem = doc.getRootElement()
attr = elem.hasNsProp('attr', 'http://abc.org')
if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
print("Failed to find defaulted attribute abc:attr")
sys.exit(1)
doc.freeDoc()
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment