install_mongo.py 845 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import sys
  2. import os
  3. import os.path
  4. import sh
  5. from sh import git, cd, make, rm, sudo
  6. def write_output(line):
  7. sys.stdout.write(line)
  8. install_env = os.environ.copy()
  9. install_env['CC'] = "gcc"
  10. directory = os.path.dirname(os.path.realpath(__file__))
  11. mongo_c_driver = os.path.join(directory, "mongo-c-driver")
  12. rm("-r", "-f", mongo_c_driver)
  13. autogen_location = os.path.join(mongo_c_driver, "autogen.sh")
  14. git.clone("https://github.com/mongodb/mongo-c-driver.git",
  15. mongo_c_driver,
  16. branch="1.1.5",
  17. depth="1",
  18. _out=write_output,
  19. )
  20. cd(mongo_c_driver)
  21. autogen = sh.Command(autogen_location)
  22. autogen(prefix="/usr", _out=write_output, _env=install_env)
  23. make(_out=write_output, _env=install_env)
  24. if os.environ.get("ZMAP_TRAVIS_BUILD", None):
  25. print("Installing...")
  26. with sudo:
  27. make.install(_out=write_output, _env=install_env)
  28. print("Done.")