editable_legacy.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """Legacy editable installation process, i.e. `setup.py develop`.
  2. """
  3. import logging
  4. from pip._internal.utils.logging import indent_log
  5. from pip._internal.utils.setuptools_build import make_setuptools_develop_args
  6. from pip._internal.utils.subprocess import call_subprocess
  7. from pip._internal.utils.typing import MYPY_CHECK_RUNNING
  8. if MYPY_CHECK_RUNNING:
  9. from typing import List, Optional, Sequence
  10. from pip._internal.build_env import BuildEnvironment
  11. logger = logging.getLogger(__name__)
  12. def install_editable(
  13. install_options, # type: List[str]
  14. global_options, # type: Sequence[str]
  15. prefix, # type: Optional[str]
  16. home, # type: Optional[str]
  17. use_user_site, # type: bool
  18. name, # type: str
  19. setup_py_path, # type: str
  20. isolated, # type: bool
  21. build_env, # type: BuildEnvironment
  22. unpacked_source_directory, # type: str
  23. ):
  24. # type: (...) -> None
  25. """Install a package in editable mode. Most arguments are pass-through
  26. to setuptools.
  27. """
  28. logger.info('Running setup.py develop for %s', name)
  29. args = make_setuptools_develop_args(
  30. setup_py_path,
  31. global_options=global_options,
  32. install_options=install_options,
  33. no_user_config=isolated,
  34. prefix=prefix,
  35. home=home,
  36. use_user_site=use_user_site,
  37. )
  38. with indent_log():
  39. with build_env:
  40. call_subprocess(
  41. args,
  42. cwd=unpacked_source_directory,
  43. )