editable_legacy.py 1.4 KB

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