You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

7 years ago
  1. """
  2. Installation paths.
  3. Map the .data/ subdirectory names to install paths.
  4. """
  5. import distutils.command.install as install
  6. import distutils.dist as dist
  7. import os.path
  8. import sys
  9. def get_install_command(name):
  10. # late binding due to potential monkeypatching
  11. d = dist.Distribution({'name': name})
  12. i = install.install(d)
  13. i.finalize_options()
  14. return i
  15. def get_install_paths(name):
  16. """
  17. Return the (distutils) install paths for the named dist.
  18. A dict with ('purelib', 'platlib', 'headers', 'scripts', 'data') keys.
  19. """
  20. paths = {}
  21. i = get_install_command(name)
  22. for key in install.SCHEME_KEYS:
  23. paths[key] = getattr(i, 'install_' + key)
  24. # pip uses a similar path as an alternative to the system's (read-only)
  25. # include directory:
  26. if hasattr(sys, 'real_prefix'): # virtualenv
  27. paths['headers'] = os.path.join(sys.prefix,
  28. 'include',
  29. 'site',
  30. 'python' + sys.version[:3],
  31. name)
  32. return paths

Powered by TurnKey Linux.