From 97db6526cbc6765cbaf9b8784e40442f59b96e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Tue, 30 Nov 2010 23:38:46 +0100 Subject: [PATCH] dh_python2: create symlinks for files installed into /usr/share/pyshared/ if there are no other public modules available --- debian/changelog | 19 ++++++++++-------- dh_python2 | 38 ++++++++++++++++++++++++++++------- tests/Makefile | 2 +- tests/t2/Makefile | 14 +++++++++++++ tests/t2/__init__.py | 1 + tests/t2/bar.py | 1 + tests/t2/debian/changelog | 5 +++++ tests/t2/debian/compat | 1 + tests/t2/debian/control | 18 +++++++++++++++++ tests/t2/debian/copyright | 2 ++ tests/t2/debian/install | 3 +++ tests/t2/debian/rules | 9 +++++++++ tests/t2/debian/source/format | 1 + tests/t2/foo.py | 1 + tests/t2/setup.py | 0 15 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 tests/t2/Makefile create mode 100644 tests/t2/__init__.py create mode 100644 tests/t2/bar.py create mode 100644 tests/t2/debian/changelog create mode 100644 tests/t2/debian/compat create mode 100644 tests/t2/debian/control create mode 100644 tests/t2/debian/copyright create mode 100644 tests/t2/debian/install create mode 100755 tests/t2/debian/rules create mode 100644 tests/t2/debian/source/format create mode 100644 tests/t2/foo.py create mode 100644 tests/t2/setup.py diff --git a/debian/changelog b/debian/changelog index da993ac..13f9fc1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,18 +1,21 @@ python-defaults (2.6.6-6) UNRELEASED; urgency=low - * Make the error message about missing extension more clear - (and more verbose in --verbose mode) - * dh_python2: install files listed in debian/pkg.pyinstall file - as public modules for all requested Python versions (use dh_install's - package.install files for private modules); remove public modules listed - in debian/pkg.pyremove (glob.glob pattern and version range can be used in - both files) + * dh_python2: + - make the error message about missing extension more clear + (and more verbose in --verbose mode) + - install files listed in debian/pkg.pyinstall file + as public modules for all requested Python versions (use dh_install's + package.install files for private modules) + - remove public modules listed in debian/pkg.pyremove (glob.glob pattern + and version range can be used in both .pyinstall and .pyremove files) + - create symlinks for files installed into /usr/share/pyshared/ if there + are no other public modules available * pycompile: - `pycompile $DESTDIR/usr/lib/python*` will recognize public site-packages directories and use the right interpreter instead of raising KeyError - do not try to check if interpreter is present when version range is - empty (closes: 605356) + empty -- Piotr Ożarowski <piotr@debian.org> Sun, 21 Nov 2010 23:49:32 +0100 diff --git a/dh_python2 b/dh_python2 index 9952d6b..6b7756f 100755 --- a/dh_python2 +++ b/dh_python2 @@ -205,6 +205,24 @@ def create_ext_links(dir1): relative_symlink(fpath1, join(dstdir, i)) +def create_public_links(dir1, vrange, root=''): + """Create public module symlinks for given directory.""" + + debian, package, path = dir1.split('/', 2) + versions = get_requested_versions(vrange) + + for fn in os.listdir(dir1): + fpath1 = join(dir1, fn) + if isdir(fpath1): + create_public_links(fpath1, vrange, join(root, fn)) + else: + for version in versions: + dstdir = join(sitedir(version, package), root) + if not exists(dstdir): + os.makedirs(dstdir) + relative_symlink(fpath1, join(dstdir, fn)) + + def share_2x(dir1, dir2, dc=None): """Move common files to pyshared and create symlinks in original locations.""" @@ -281,6 +299,7 @@ def scan(package, dname=None): ('usr/lib/%s', 'usr/lib/games/%s', 'usr/share/%s', 'usr/share/games/%s')] else: + # scan private directory *only* proot = join('debian', package, dname.strip('/')) private_to_check = [dname[1:]] @@ -484,13 +503,18 @@ def main(): options.arch is True and pdetails['arch'] == 'all': continue log.debug('processing package %s...', package) - if not pyinstall(package, options.vrange): - exit(4) - if not pyremove(package, options.vrange): - exit(5) - fix_locations(package) + if not private_dir: + if not pyinstall(package, options.vrange): + exit(4) + if not pyremove(package, options.vrange): + exit(5) + fix_locations(package) stats = scan(package, private_dir) - share(package, stats, options) + if not private_dir: + share(package, stats, options) + pyshared_dir = "debian/%s/usr/share/pyshared/" % package + if not stats['public_vers'] and exists(pyshared_dir): + create_public_links(pyshared_dir, options.vrange) dependencies = Dependencies(package, dh.packages[package]['uses_breaks']) @@ -524,7 +548,7 @@ def main(): ext_for = details.get('public_ext') if ext_for is None: # no extension - if options.vrange: + if options.vrange and options.vrange != (None, None): args += " -V %s" % vrange_str(options.vrange) elif ext_for is False: # extension's version not detected if options.vrange and '-' not in vrange_str(options.vrange): diff --git a/tests/Makefile b/tests/Makefile index 9d93824..61610d2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f # enable or disable tests here: -TESTS := test1 +TESTS := test1 test2 all: $(TESTS) diff --git a/tests/t2/Makefile b/tests/t2/Makefile new file mode 100644 index 0000000..7ebf2ce --- /dev/null +++ b/tests/t2/Makefile @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +all: run check + + +run: clean + dpkg-buildpackage -b -us -uc + +check: + test -f debian/python-foo/usr/lib/python2.6/dist-packages/foo.py + test -f debian/python-foo/usr/lib/python2.6/dist-packages/bar/bar.py + +clean: + ./debian/rules clean diff --git a/tests/t2/__init__.py b/tests/t2/__init__.py new file mode 100644 index 0000000..4c96663 --- /dev/null +++ b/tests/t2/__init__.py @@ -0,0 +1 @@ +print("I'm __init__.py") diff --git a/tests/t2/bar.py b/tests/t2/bar.py new file mode 100644 index 0000000..f64f123 --- /dev/null +++ b/tests/t2/bar.py @@ -0,0 +1 @@ +print("I'm bar") diff --git a/tests/t2/debian/changelog b/tests/t2/debian/changelog new file mode 100644 index 0000000..0f9a168 --- /dev/null +++ b/tests/t2/debian/changelog @@ -0,0 +1,5 @@ +foo (0.1.1) unstable; urgency=low + + * Initial release + + -- Piotr Ożarowski <piotr@debian.org> Sat, 27 Feb 2010 20:42:17 +0100 diff --git a/tests/t2/debian/compat b/tests/t2/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/tests/t2/debian/compat @@ -0,0 +1 @@ +7 diff --git a/tests/t2/debian/control b/tests/t2/debian/control new file mode 100644 index 0000000..84f434f --- /dev/null +++ b/tests/t2/debian/control @@ -0,0 +1,18 @@ +Source: foo +Section: python +Priority: optional +Maintainer: Piotr Ożarowski <piotr@debian.org> +Build-Depends: debhelper (>= 7.0.50~) +Build-Depends-Indep: python-all +Standards-Version: 3.9.1 +XS-Python-Version: >= 2.1 + +Package: python-foo +Architecture: all +Depends: ${python:Depends}, ${misc:Depends} +Recommends: ${python:Recommends} +Suggests: ${python:Suggests} +Enhances: ${python:Enhances} +Breaks: ${python:Breaks} +Description: foo to rule them all + exemple package #2 diff --git a/tests/t2/debian/copyright b/tests/t2/debian/copyright new file mode 100644 index 0000000..6382944 --- /dev/null +++ b/tests/t2/debian/copyright @@ -0,0 +1,2 @@ +The Debian packaging is © 2010, Piotr Ożarowski <piotr@debian.org> and +is licensed under the MIT License. diff --git a/tests/t2/debian/install b/tests/t2/debian/install new file mode 100644 index 0000000..e3e06e3 --- /dev/null +++ b/tests/t2/debian/install @@ -0,0 +1,3 @@ +foo.py /usr/share/pyshared/ +__init__.py /usr/share/pyshared/bar/ +bar.py /usr/share/pyshared/bar/ diff --git a/tests/t2/debian/rules b/tests/t2/debian/rules new file mode 100755 index 0000000..0b2b58b --- /dev/null +++ b/tests/t2/debian/rules @@ -0,0 +1,9 @@ +#!/usr/bin/make -f +%: + dh $@ --buildsystem=python_distutils + +override_dh_pysupport: + DH_VERBOSE=1 ../../dh_python2 + +clean: + dh_clean diff --git a/tests/t2/debian/source/format b/tests/t2/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/tests/t2/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/tests/t2/foo.py b/tests/t2/foo.py new file mode 100644 index 0000000..8e4dd8e --- /dev/null +++ b/tests/t2/foo.py @@ -0,0 +1 @@ +print("I'm foo") diff --git a/tests/t2/setup.py b/tests/t2/setup.py new file mode 100644 index 0000000..e69de29 -- GitLab