2

I'm trying to do a distribution upgrade from Debian 6 to 7 and am having some issues with some packages I created and installed with checkinstall. When doing the upgrade I get the following message:

Preparing to replace python 2.6.6-3+squeeze7 (using .../python_2.7.3-4+deb7u1_all.deb) ...
Unpacking replacement python ...
dpkg: error processing /var/cache/apt/archives/python_2.7.3-4+deb7u1_all.deb (--unpack):
 trying to overwrite '/usr/bin/2to3', which is also in package python3.4.0 3.4.0-1

This is due to the 2to3 installed in my python3.4.0 package. I created and installed that package with this line:

checkinstall -D --fstrans=no --dpkgflags=--force-overwrite \
    [email protected] --backup=yes \
    --pkgname=python3.4.0 --pkgversion=3.4.0 make install

In hindsight it probably wasn't the best idea to use --force-overwrite but that was the only way I could get the package to install.

I'd like to finishing installing the python_2.7.3-4+deb7u1_all package but tell it to use the file installed by python3.4.0 and not overwrite it. Additionally, I'd like to repackage my python3.4.0 so I can properly install it without using --force-overwrite and tell the system to use the newest version of 2to3 instead of the one provided by the py2.7 package. (hopefully to avoid further issues later)

Tim Tisdall
  • 161
  • 1
  • 7

2 Answers2

1

You should not worry about overwriting the file, the bin/2to3 file is a 5 line script that only differs in the first line (the binary python version it invokes):

$ diff -u bin/2to3 ../2.7.8
--- bin/2to3    2014-06-24 16:39:43.000000000 +0200
+++ ../2.7.8/bin/2to3   2014-07-21 18:45:32.000000000 +0200
@@ -1,4 +1,4 @@
-#! /opt/python/3.4.1/bin/python3.4
+#! /opt/python/2.7.8/bin/python2.7
 import sys
 from lib2to3.main import main

2to3 is actually a link to 2to3-2.7 resp. 2to3-3.4.

However I recommend to not install the binary from 2.7.3 (released 2012-04-09) you have as the modules for 2to3 included with 3.4.0 release are more up to date (released 2014-03-16).

If you do a separate install of (in my case) 2.7.8 and 3.4.1 you get four directories: bin, include, lib and share.

  • Under share are only man pages, with names like python3.4.1 so such names don't clash (even if they go in the same directory).
  • Under under lib and include are differentiations between python3.4 resp python2.7 as well, so there will be no clashes either.
  • under bin, there are several links (2to3, idle, pydoc, python, etc.) to version specific binaries.

Of course you want some python command (or 2to3) you just need to decide which version should be default.

Python has been capable of being installed with multiple major.minor versions next to each other for 10+ years, you just need to decide which of the versions sets the symlinks ( and thus is the version invoked with just python)

Anthon
  • 78,313
  • 42
  • 165
  • 222
  • ok... so.. how? py2.7 needs to be installed to complete the dist upgrade and it won't complete because the 2to3 file is in the way from py3.4. How do I tell it to finish installing without overwriting the files? – Tim Tisdall Sep 29 '14 at 18:03
  • also, I suspect that `2to3` is only the first file it complains about overwriting and there's likely more even if that file wasn't there... – Tim Tisdall Sep 29 '14 at 18:04
  • @TimTisdall see the update to my answer, you should just not include the symlinks to the real executables under bin for the version you don't want to invoke without the major-minor extension (i.e. `python2.7` or `python3.4`) – Anthon Sep 29 '14 at 18:23
  • sorry, I'm still unclear as to how I should proceed. Are you saying I should use `--force-overwrite` to proceed with the upgrade than then fix the symlinks to point to the newer ones afterwards? I already know that I want to have the symlinks pointing the newer versions, but my issue is on how to do it within `apt-get` and `dpkg`. – Tim Tisdall Sep 29 '14 at 18:29
  • @TimTisdall First decide on which version you want to get when you do `python` (either select 2.7.3 or 3.4.0) then for the other one remove the symlinks without version number from the bin directory before doing the `make install` (i.e. if you select 2.7.3 to be the "default" python, you can leave symlink `python3` in place but you remove `python` before running `make install` under the 3.4.0 directory. idem for `2to3`, `idle`, `easy-install`, `pydoc` etc *all the symlinks that are available for both*, **there are no binaries with the same names** – Anthon Sep 29 '14 at 18:36
  • AFAIK there is no `make install` variant that doesn't include symlinks. That would be difficult because 3.4 series have some extra commands (like `pyvenv` why not install that symlink if the "main" python (from the 2.7 series) doesn't have that command at all? But you have to do something about that if you combine 3.3 and 3.4 in one environment. – Anthon Sep 29 '14 at 18:39
  • I guess I was hoping for more functionality in dpkg than is available. I was thinking that you might be able to say (somehow) that the 3.4 version of "2to3" should have priority over the 2.7 version. I guess you can only do that if you have the 3.4 package actually replace the 2.7 one. – Tim Tisdall Sep 29 '14 at 18:44
  • No I think the decision you have to make about `python`, what you can do in .deb/.rpm files is create the links in the scripts if not yet there. But then installation order is important (as normally the system expects a particular version and might not use `#/usr/bin/env pythonX.Y` in every system util programmed in python. – Anthon Sep 29 '14 at 18:49
  • I tried removing `/usr/bin/2to3` and then `apt-get -f install` only to see the same error. Apparently it still sees that file in the py3.4 .deb package and won't budge (despite the actual file not being there). – Tim Tisdall Sep 29 '14 at 19:13
  • @TimTisdall As I already wrote, you have to remove that file from your compilation subdir, **before** doing `make install` (as part of your checkinstall stuff). – Anthon Sep 29 '14 at 19:31
0

The corrected command to create the package:

checkinstall -D --fstrans=no \
[email protected] --backup=yes \
--pkgname=python3.4.0 --pkgversion=3.4.0 make altinstall

altinstall will stop the creation of 2to3, python, etc and just install the version specific names (2to3-3.4, python3.4 in this case). The generic names are just symbolic links.

Tim Tisdall
  • 161
  • 1
  • 7