site.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2013-2021, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. """
  12. This is a fake 'site' module available in default Python Library.
  13. The real 'site' does some magic to find paths to other possible
  14. Python modules. We do not want this behaviour for frozen applications.
  15. Fake 'site' makes PyInstaller to work with distutils and to work inside
  16. virtualenv environment.
  17. """
  18. # Marker to be used in our test-suite.
  19. __pyinstaller__faked__site__module__ = True
  20. # TODO test the following code stub from real 'site' module.
  21. # Prefixes for site-packages; add additional prefixes like /usr/local here
  22. PREFIXES = []
  23. # Enable per user site-packages directory
  24. # set it to False to disable the feature or True to force the feature
  25. ENABLE_USER_SITE = False
  26. # For distutils.commands.install
  27. # These values are initialized by the getuserbase() and getusersitepackages()
  28. # functions, through the main() function when Python starts.
  29. # Issue #1699: Freezing pip requires 'site.USER_SITE' to be a 'str' not None.
  30. USER_SITE = ''
  31. # Freezing Jupyter Notebook requires 'site.USER_BASE' to be a 'str' not None.
  32. USER_BASE = ''
  33. # Package IPython depends on the following functionality from real site.py.
  34. # This code could be probably removed when the following bug is fixed:
  35. # https://github.com/ipython/ipython/issues/2606
  36. class _Helper(object):
  37. """
  38. Define the builtin 'help'.
  39. This is a wrapper around pydoc.help (with a twist).
  40. """
  41. def __repr__(self):
  42. return "Type help() for interactive help, " \
  43. "or help(object) for help about object."
  44. def __call__(self, *args, **kwds):
  45. # Do *not* use `import` here, otherwise pydoc will be included in
  46. # *every* frozen app
  47. pydoc = __import__(''.join('pydoc'))
  48. return pydoc.help(*args, **kwds)