develop.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import site
  2. import subprocess
  3. import sys
  4. from typing import cast
  5. from setuptools import Command
  6. from setuptools.warnings import SetuptoolsDeprecationWarning
  7. class develop(Command):
  8. """Set up package for development"""
  9. user_options = [
  10. ("install-dir=", "d", "install package to DIR"),
  11. ('no-deps', 'N', "don't install dependencies"),
  12. ('user', None, f"install in user site-package '{site.USER_SITE}'"),
  13. ('prefix=', None, "installation prefix"),
  14. ("index-url=", "i", "base URL of Python Package Index"),
  15. ]
  16. boolean_options = [
  17. 'no-deps',
  18. 'user',
  19. ]
  20. install_dir = None
  21. no_deps = False
  22. user = False
  23. prefix = None
  24. index_url = None
  25. def run(self) -> None:
  26. # Casting because mypy doesn't understand bool mult conditionals
  27. cmd = cast(
  28. list[str],
  29. [sys.executable, '-m', 'pip', 'install', '-e', '.', '--use-pep517']
  30. + ['--target', self.install_dir] * bool(self.install_dir)
  31. + ['--no-deps'] * self.no_deps
  32. + ['--user'] * self.user
  33. + ['--prefix', self.prefix] * bool(self.prefix)
  34. + ['--index-url', self.index_url] * bool(self.index_url),
  35. )
  36. subprocess.check_call(cmd)
  37. def initialize_options(self) -> None:
  38. DevelopDeprecationWarning.emit()
  39. def finalize_options(self) -> None:
  40. pass
  41. class DevelopDeprecationWarning(SetuptoolsDeprecationWarning):
  42. _SUMMARY = "develop command is deprecated."
  43. _DETAILS = """
  44. Please avoid running ``setup.py`` and ``develop``.
  45. Instead, use standards-based tools like pip or uv.
  46. """
  47. _SEE_URL = "https://github.com/pypa/setuptools/issues/917"
  48. _DUE_DATE = 2025, 10, 31