wheel.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import logging
  2. import os
  3. from typing import Optional
  4. from pip._vendor.pep517.wrappers import Pep517HookCaller
  5. from pip._internal.utils.subprocess import runner_with_spinner_message
  6. logger = logging.getLogger(__name__)
  7. def build_wheel_pep517(
  8. name, # type: str
  9. backend, # type: Pep517HookCaller
  10. metadata_directory, # type: str
  11. tempd, # type: str
  12. ):
  13. # type: (...) -> Optional[str]
  14. """Build one InstallRequirement using the PEP 517 build process.
  15. Returns path to wheel if successfully built. Otherwise, returns None.
  16. """
  17. assert metadata_directory is not None
  18. try:
  19. logger.debug('Destination directory: %s', tempd)
  20. runner = runner_with_spinner_message(
  21. f'Building wheel for {name} (PEP 517)'
  22. )
  23. with backend.subprocess_runner(runner):
  24. wheel_name = backend.build_wheel(
  25. tempd,
  26. metadata_directory=metadata_directory,
  27. )
  28. except Exception:
  29. logger.error('Failed building wheel for %s', name)
  30. return None
  31. return os.path.join(tempd, wheel_name)