installEmQuantAPI.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. __author__ = 'weijie'
  2. from EmQuantAPI import *
  3. import sys as _sys, os as _os
  4. def installEmQuantAPI():
  5. print("Start to install EmQuantAPI...")
  6. if UtilAccess.adapter.get_py_name() != PY_Python3:
  7. print('Error: Python version must be 3.x!')
  8. return
  9. currDir = _os.path.split(_os.path.realpath(__file__))[0]
  10. site_pkg_names = ["site-packages"]
  11. if(UtilAccess.adapter.get_os_name() == OS_Linux):
  12. site_pkg_names.append("dist-packages")
  13. #get site-packages path
  14. packagepath = ""
  15. for site_pkg_name in site_pkg_names:
  16. if packagepath != "":
  17. break
  18. for spath in _sys.path:
  19. pos = spath.find(site_pkg_name)
  20. if(pos >= 0 and spath[pos:]==site_pkg_name):
  21. packagepath = spath
  22. break
  23. if packagepath != "":
  24. pthPath = _os.path.join(packagepath, "EmQuantAPI.pth")
  25. pthFile = open(pthPath, "w")
  26. pthFile.writelines(currDir)
  27. pthFile.close()
  28. print("Success:", "EmQuantAPI installed.")
  29. else:
  30. print( "Error: EmQuantApi install fail!(in get pth)")
  31. if __name__ == "__main__":
  32. installEmQuantAPI()