From 15136f78407904cc7ec170b8a20b6f5dadcc1e8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20O=C5=BCarowski?= <piotr@debian.org> Date: Sun, 12 Jun 2011 22:59:01 +0200 Subject: [PATCH] add --ignore-namespace option that will disable handling Egg-info's namespace_packages.txt (AKA namespace feature) --- debian/changelog | 2 ++ dh_python2 | 25 +++++++++++++++++-------- dh_python2.rst | 5 +++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 11ddac2..df7e01c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ python-defaults (2.7.2-2) UNRELEASED; urgency=low Leonid Borisenko for the original patch) - add --ignore-shebangs option that will disable translating shebangs into Debian dependencies + - add --ignore-namespace option that will disable handling + Egg-info's namespace_packages.txt (AKA namespace feature) -- Piotr Ożarowski <piotr@debian.org> Sun, 12 Jun 2011 13:28:48 +0200 diff --git a/dh_python2 b/dh_python2 index b441dec..f512ba7 100755 --- a/dh_python2 +++ b/dh_python2 @@ -257,7 +257,8 @@ def share_2x(dir1, dir2, dc=None): # directories with .so files will be blocked earlier common_files.append(i) elif islink(dir1): - # skip this symlink in pyshared (dpkg has problems with symlinks anyway) + # skip this symlink in pyshared + # (dpkg has problems with symlinks anyway) common_dirs = [] common_files = [] else: @@ -488,6 +489,8 @@ def main(): help='generate maintainer script that will remove pycentral files') parser.add_option('--ignore-shebangs', action='store_true', default=False, help='do not translate shebangs into Debian dependencies') + parser.add_option('--ignore-namespace', action='store_true', default=False, + help="ignore Egg's namespace_packages.txt file and --namespace option") # ignore some debhelper options: parser.add_option('-O', help=SUPPRESS_HELP) @@ -572,7 +575,8 @@ def main(): pyclean_added = False # invoke pyclean only once in maintainer script if stats['compile']: if options.clean_pycentral: - dh.autoscript(package, 'preinst', 'preinst-pycentral-clean', '') + dh.autoscript(package, 'preinst', + 'preinst-pycentral-clean', '') dh.autoscript(package, 'postinst', 'postinst-pycompile', '') dh.autoscript(package, 'prerm', 'prerm-pyclean', '') pyclean_added = True @@ -622,14 +626,19 @@ def main(): fcopy(pydist_file, join(dstdir, package)) # namespace feature - recreate __init__.py files at install time - nsp = ns.parse(stats['nsp.txt'], options.namespaces) + if options.ignore_namespace: + nsp = None + else: + nsp = ns.parse(stats['nsp.txt'], options.namespaces) # note that pycompile/pyclean is already added to maintainer scripts # and it should remain there even if __init__.py was the only .py file - try: - nsp = ns.remove_from_package(package, nsp, stats['public_vers']) - except (IOError, OSError), e: - log.error('cannot remove __init__.py from package: %s', e) - exit(6) + if nsp: + try: + nsp = ns.remove_from_package(package, nsp, + stats['public_vers']) + except (IOError, OSError), e: + log.error('cannot remove __init__.py from package: %s', e) + exit(6) if nsp: dstdir = join('debian', package, 'usr/share/python/ns/') if not exists(dstdir): diff --git a/dh_python2.rst b/dh_python2.rst index bc2db93..4f5dc6b 100644 --- a/dh_python2.rst +++ b/dh_python2.rst @@ -97,6 +97,11 @@ OPTIONS --namespace use this option (multiple time if necessary) if namespace_packages.txt is not complete +--ignore-namespace ignore Egg's namespace declaration and + --namespace option. This option will disable removing (and recreating at + install time) empty __init__.py files. Removing namespace_packages.txt from + egg-info directory has the same effect. + --clean-pycentral generate maintainer script that will remove byte code generated by python-central helper -- GitLab