develop.py 1.6 KB

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