site.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 Python modules. We do not want this behaviour for
  14. frozen applications.
  15. Fake 'site' makes PyInstaller to work with distutils and to work inside virtualenv environment.
  16. """
  17. # Marker to be used in our test-suite.
  18. __pyinstaller__faked__site__module__ = True
  19. # TODO test the following code stub from real 'site' module.
  20. # Prefixes for site-packages; add additional prefixes like /usr/local here.
  21. PREFIXES = []
  22. # Enable per user site-packages directory. Set it to False to disable the feature or True to force the feature.
  23. ENABLE_USER_SITE = False
  24. # For distutils.commands.install. These values are initialized by the getuserbase() and getusersitepackages() functions,
  25. # through the main() function when Python starts.
  26. # Issue #1699: Freezing pip requires 'site.USER_SITE' to be a 'str' not None.
  27. USER_SITE = ''
  28. # Freezing Jupyter Notebook requires 'site.USER_BASE' to be a 'str' not None.
  29. USER_BASE = ''
  30. # Package IPython depends on the following functionality from real site.py. This code could be probably removed when the
  31. # following bug is fixed: https://github.com/ipython/ipython/issues/2606
  32. class _Helper(object):
  33. """
  34. Define the builtin 'help'. This is a wrapper around pydoc.help (with a twist).
  35. """
  36. def __repr__(self):
  37. return "Type help() for interactive help, or help(object) for help about object."
  38. def __call__(self, *args, **kwds):
  39. # Do *not* use `import` here, otherwise pydoc will be included in *every* frozen app.
  40. pydoc = __import__(''.join('pydoc'))
  41. return pydoc.help(*args, **kwds)