1
0

validate_taipy_install.py 1.6 KB

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