setup.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. from setuptools import setup
  5. from setuptools.command.build import build as BuildCommand
  6. from setuptools.command.develop import develop as DevelopCommand
  7. from setuptools.command.sdist import sdist as SDistCommand
  8. ROOT = os.path.dirname(os.path.abspath(__file__))
  9. # add sentry to path so we can import sentry.utils.distutils
  10. sys.path.insert(0, os.path.join(ROOT, "src"))
  11. from sentry.utils.distutils.commands.build_assets import BuildAssetsCommand
  12. from sentry.utils.distutils.commands.build_integration_docs import BuildIntegrationDocsCommand
  13. from sentry.utils.distutils.commands.build_js_sdk_registry import BuildJsSdkRegistryCommand
  14. IS_LIGHT_BUILD = os.environ.get("SENTRY_LIGHT_BUILD") == "1"
  15. class SentrySDistCommand(SDistCommand):
  16. # If we are not a light build we want to also execute build_assets as
  17. # part of our source build pipeline.
  18. if not IS_LIGHT_BUILD:
  19. sub_commands = [
  20. *SDistCommand.sub_commands,
  21. ("build_integration_docs", None),
  22. ("build_assets", None),
  23. ("build_js_sdk_registry", None),
  24. ]
  25. class SentryBuildCommand(BuildCommand):
  26. def run(self):
  27. import logging
  28. logging.getLogger("sentry").setLevel(logging.WARNING)
  29. if not IS_LIGHT_BUILD:
  30. self.run_command("build_integration_docs")
  31. self.run_command("build_assets")
  32. self.run_command("build_js_sdk_registry")
  33. BuildCommand.run(self)
  34. class SentryDevelopCommand(DevelopCommand):
  35. def run(self):
  36. DevelopCommand.run(self)
  37. if not IS_LIGHT_BUILD:
  38. self.run_command("build_integration_docs")
  39. self.run_command("build_assets")
  40. self.run_command("build_js_sdk_registry")
  41. cmdclass = {
  42. "sdist": SentrySDistCommand,
  43. "develop": SentryDevelopCommand,
  44. "build": SentryBuildCommand,
  45. "build_assets": BuildAssetsCommand,
  46. "build_integration_docs": BuildIntegrationDocsCommand,
  47. "build_js_sdk_registry": BuildJsSdkRegistryCommand,
  48. }
  49. setup(cmdclass=cmdclass)