Comment 6 for bug 362570

Revision history for this message
Colin Watson (cjwatson) wrote :

Matthias: I think the problem here is that the logic for selecting between dist-packages and site-packages is not consistent. Ignoring --install-layout for a moment, distutils.sysconfig says, in effect:

  is_default_prefix = not prefix or os.path.normpath(prefix) in ('/usr', '/usr/local')
  if is_default_prefix and 'PYTHONUSERBASE' not in os.environ and 'real_prefix' not in sys.__dict__:
      return os.path.join(libpython, "dist-packages")

... while distutils.command.install says, in effect:

  if self.prefix_option or 'real_prefix' in sys.__dict__:
      self.select_scheme("unix_prefix")
  else:
      self.select_scheme("unix_local")

I think that we should be consistent here, and apply the same "is the prefix /usr or /usr/local?" check in distutils.command.install (and perhaps check PYTHONUSERBASE too, though that's a side issue) - if it is, we should use the unix_local scheme and thus install into dist-packages rather than site-packages.

This bug seems more important than wishlist - it breaks third-party build systems that use --prefix=/usr/local in the expectation that it will install things somewhere sensible where the version of python you're using will be able to get at them. (Such build systems can simply remove --prefix=/usr/local as a workaround, but with older packaged versions of python in Debian/Ubuntu that will install into /usr which is obviously undesirable.)