Advertisement
anacrolix

Untitled

Apr 5th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. from os.path import *
  3. import sys
  4. from sys import argv
  5. package = "."
  6. for package_argv_index, arg in enumerate(argv[1:], start=1):
  7.     if arg == "--":
  8.         break
  9.     if not arg.startswith('-'):
  10.         package = arg
  11.         break
  12. import os
  13. import tempfile
  14. GOBIN = tempfile.gettempdir()
  15. os.environ['GOBIN'] = GOBIN
  16. import subprocess
  17. GOEXE = subprocess.check_output('go env GOEXE', shell=True).decode().strip()
  18. exe = join(GOBIN, basename(realpath(package))) + GOEXE
  19. args = ['go', 'install']+argv[1:package_argv_index]+[package]
  20. rc = subprocess.call(args)
  21. if rc != 0:
  22.     sys.exit(rc)
  23. args = [exe]+argv[package_argv_index+1:]
  24. print(exe, args)
  25. os.execv(exe, args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement