Skip to content
Snippets Groups Projects
Commit 2d5d0da5 authored by Piotr Ożarowski's avatar Piotr Ożarowski
Browse files

* dh_python2: Create extension symlinks in /usr/lib/pyshared/pythonX.Y

* debian/copyright: Add a note about dh_python2, pycompile, pyclean and
  debpython module in
parent c5ce1c3f
No related branches found
No related tags found
No related merge requests found
python-defaults (2.6.5-2) UNRELEASED; urgency=low python-defaults (2.6.5-2) UNRELEASED; urgency=low
* [ Piotr Ożarowski ]
* dh_python2: Create extension symlinks in /usr/lib/pyshared/pythonX.Y
* debian/copyright: Add a note about dh_python2, pycompile, pyclean and
debpython module in
-- Matthias Klose <doko@debian.org> Tue, 18 May 2010 12:28:25 +0200 -- Matthias Klose <doko@debian.org> Tue, 18 May 2010 12:28:25 +0200
......
...@@ -271,3 +271,26 @@ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ...@@ -271,3 +271,26 @@ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dh_python2, pycompile, pyclean and debpython module:
====================================================
Copyright © 2010 Piotr Ożarowski <piotr@debian.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
...@@ -46,7 +46,7 @@ logging.basicConfig(format='%(levelname).1s: %(module)s:%(lineno)d: ' ...@@ -46,7 +46,7 @@ logging.basicConfig(format='%(levelname).1s: %(module)s:%(lineno)d: '
log = logging.getLogger('dh_python') log = logging.getLogger('dh_python')
os.umask(022) os.umask(022)
EGGnPTH_RE = re.compile(r'(.*?)(-py\d\.\d+)(.*?)(\.egg-info|\.pth)$') # FIXME: optional group(2) EGGnPTH_RE = re.compile(r'(.*?)(-py\d\.\d+)?(.*?)(\.egg-info|\.pth)$')
PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d.\d+)/(site|dist)-packages') PUBLIC_DIR_RE = re.compile(r'.*?/usr/lib/python(\d.\d+)/(site|dist)-packages')
...@@ -132,12 +132,15 @@ def share(package, stats, options): ...@@ -132,12 +132,15 @@ def share(package, stats, options):
# TODO: remove this once file conflicts will not be needed anymore # TODO: remove this once file conflicts will not be needed anymore
move_to_pyshared(sitedir(pv_2x[0], package)) move_to_pyshared(sitedir(pv_2x[0], package))
for version in stats['public_ext']:
create_ext_links(sitedir(version, package))
if options.guess_versions and pv_2x: if options.guess_versions and pv_2x:
versions = get_requested_versions(options.vrange) versions = get_requested_versions(options.vrange)
for version in (i for i in versions if i[0] == 2): for version in (i for i in versions if i[0] == 2):
if version not in pv_2x: if version not in pv_2x:
log.debug('guessing files for Python %s', vrepr(version)) log.debug('guessing files for Python %s', vrepr(version))
versions_without_ext = debsorted(set(pv_2x) - stats['ext_for']) versions_without_ext = debsorted(set(pv_2x) - stats['public_ext'])
if not versions_without_ext: if not versions_without_ext:
log.error('you most probably have to build extension ' log.error('you most probably have to build extension '
'for python%s.', vrepr(version)) 'for python%s.', vrepr(version))
...@@ -151,10 +154,8 @@ def share(package, stats, options): ...@@ -151,10 +154,8 @@ def share(package, stats, options):
def move_to_pyshared(dir1): def move_to_pyshared(dir1):
# dir1 starts with debian/packagename/usr/lib/pythonX.Y/*-packages/ # dir1 starts with debian/packagename/usr/lib/pythonX.Y/*-packages/
debian, package, path = dir1.split('/', 2) debian, package, path = dir1.split('/', 2)
dstdir = join(debian, package, 'usr/share/pyshared/',\ dstdir = join(debian, package, 'usr/share/pyshared/', \
'/'.join(dir1.split('/')[6:])) '/'.join(dir1.split('/')[6:]))
if not exists(dstdir):
os.makedirs(dstdir)
fext = lambda fname: fname.rsplit('.', 1)[-1] fext = lambda fname: fname.rsplit('.', 1)[-1]
...@@ -169,10 +170,37 @@ def move_to_pyshared(dir1): ...@@ -169,10 +170,37 @@ def move_to_pyshared(dir1):
continue continue
fpath2 = join(dstdir, i) fpath2 = join(dstdir, i)
if not exists(fpath2): if not exists(fpath2):
if not exists(dstdir):
os.makedirs(dstdir)
os.rename(fpath1, fpath2) os.rename(fpath1, fpath2)
relative_symlink(fpath2, fpath1) relative_symlink(fpath2, fpath1)
def create_ext_links(dir1):
"""Create extension symlinks in /usr/lib/pyshared/pythonX.Y.
These symlinks are used to let dpkg detect file conflicts with
python-support and python-central packages.
"""
debian, package, path = dir1.split('/', 2)
python, _, module_subpath = path[8:].split('/', 2)
dstdir = join(debian, package, 'usr/lib/pyshared/', python, module_subpath)
for i in os.listdir(dir1):
fpath1 = join(dir1, i)
if isdir(fpath1):
create_ext_links(fpath1)
elif i.rsplit('.', 1)[-1] == 'so':
fpath2 = join(dstdir, i)
if exists(fpath2):
continue
if not exists(dstdir):
os.makedirs(dstdir)
print fpath1, join(dstdir, i)
relative_symlink(fpath1, join(dstdir, i))
def share_2x(dir1, dir2, dc=None): def share_2x(dir1, dir2, dc=None):
"""Move common files to pyshared and create symlinks in original """Move common files to pyshared and create symlinks in original
locations.""" locations."""
...@@ -241,7 +269,7 @@ def scan(package, dname=None): ...@@ -241,7 +269,7 @@ def scan(package, dname=None):
'public_vers': set(), 'public_vers': set(),
'private_dirs': {}, 'private_dirs': {},
'compile': False, 'compile': False,
'ext_for': set()} 'public_ext': set()}
dbg_package = package.endswith('-dbg') dbg_package = package.endswith('-dbg')
...@@ -316,7 +344,7 @@ def scan(package, dname=None): ...@@ -316,7 +344,7 @@ def scan(package, dname=None):
if fext == 'so': if fext == 'so':
(r if public_dir else (r if public_dir else
r['private_dirs'].setdefault(private_dir, {}))\ r['private_dirs'].setdefault(private_dir, {}))\
['ext_for'].add(version) ['public_ext'].add(version)
continue continue
elif fext == 'py': elif fext == 'py':
(r if public_dir else (r if public_dir else
...@@ -341,9 +369,9 @@ def scan(package, dname=None): ...@@ -341,9 +369,9 @@ def scan(package, dname=None):
if dbg_package: if dbg_package:
# remove empty directories in -dbg packages # remove empty directories in -dbg packages
proot = proot + 'usr/lib' proot = proot + '/usr/lib'
for root, dirs, file_names in os.walk(proot, topdown=False): for root, dirs, file_names in os.walk(proot, topdown=False):
if '-packages/' in root: if '-packages/' in root and not file_names:
try: try:
os.rmdir(root) os.rmdir(root)
except: except:
...@@ -542,7 +570,7 @@ def main(): ...@@ -542,7 +570,7 @@ def main():
args = "-p %s %s" % (package, private_dir) args = "-p %s %s" % (package, private_dir)
inst_args = '' inst_args = ''
ext_for = details.get('ext_for') ext_for = details.get('public_ext')
if ext_for is None: # no extension if ext_for is None: # no extension
if options.vrange: if options.vrange:
inst_args += " -V %s" % vrange_str(options.vrange) inst_args += " -V %s" % vrange_str(options.vrange)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment