validate_taipy_install.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import logging
  2. import sys
  3. def test_import_taipy_packages() -> bool:
  4. """
  5. Import taipy package and call gui, Scenario and rest attributes.
  6. """
  7. import taipy as tp
  8. valid_install = True
  9. if not hasattr(tp, "gui"):
  10. logging.error("Taipy installation has no attribute gui")
  11. valid_install = False
  12. if not hasattr(tp, "Scenario"):
  13. logging.error("Taipy installation has no attribute Scenario")
  14. valid_install = False
  15. if not hasattr(tp, "rest"):
  16. logging.error("Taipy installation has no attribute rest")
  17. valid_install = False
  18. return valid_install
  19. def test_taipy_gui_core() -> bool:
  20. import taipy
  21. from pathlib import Path
  22. taipy_gui_core_path = Path(taipy.__file__).absolute().parent / "gui_core" / "lib" / "taipy-gui-core.js"
  23. if not taipy_gui_core_path.exists():
  24. logging.error("File taipy-gui-core.js not found in taipy installation path")
  25. return False
  26. return True
  27. if __name__ == "__main__":
  28. logging.basicConfig(level=logging.INFO)
  29. logging.info("Trying to import taipy and verify it's main attributes")
  30. if not test_import_taipy_packages() or not test_taipy_gui_core():
  31. sys.exit(1)
  32. logging.info("Taipy installation Validated")
  33. sys.exit(0)