__main__.py 854 B

123456789101112131415161718192021222324
  1. import os
  2. import sys
  3. # Remove '' and current working directory from the first entry
  4. # of sys.path, if present to avoid using current directory
  5. # in pip commands check, freeze, install, list and show,
  6. # when invoked as python -m pip <command>
  7. if sys.path[0] in ("", os.getcwd()):
  8. sys.path.pop(0)
  9. # If we are running from a wheel, add the wheel to sys.path
  10. # This allows the usage python pip-*.whl/pip install pip-*.whl
  11. if __package__ == "":
  12. # __file__ is pip-*.whl/pip/__main__.py
  13. # first dirname call strips of '/__main__.py', second strips off '/pip'
  14. # Resulting path is the name of the wheel itself
  15. # Add that to sys.path so we can import pip
  16. path = os.path.dirname(os.path.dirname(__file__))
  17. sys.path.insert(0, path)
  18. if __name__ == "__main__":
  19. from pip._internal.cli.main import main as _main
  20. sys.exit(_main())