 ;;(setenv "PYTHONHOME" "~/.elpy-libraries/easy_install")
 
 (elpy-enable)
-;; (pyvenv-activate "~/.elpy-virtualenv")
+(condition-case nil
+    (if (file-exists-p "~/.elpy-virtualenv")
+        (pyvenv-activate "~/.elpy-virtualenv")
+      (warn "No virtualenv found at ~/.elpy-virtualenv"))
+  (error "Failed to init elpy virtualenv"))
 
 ;;;;;;;;;;;;;;;
 ;; Lua stuff ;;

;; rtags setup ;;
;;;;;;;;;;;;;;;;;

(if (executable-find "rc")
  (condition-case nil ; The following commands will fail if rtags is not installed.
    (progn
      (require 'rtags)
      (require 'company)
      (require 'flycheck-rtags)

      (setq rtags-autostart-diagnostics t)
      (rtags-diagnostics)
      (setq rtags-completions-enabled t)

;; (Cisco Aurora specific)                                                          ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (file-exists-p "/home/wvanders/pkgs/bin")
    (progn
      (setenv "PATH"
              (concat
               "/home/wvanders/pkgs/bin" ":"
               (getenv "PATH"))))
  
  (setenv "LD_LIBRARY_PATH"
          (concat
           "/home/wvanders/pkgs/lib" ":"
           "/home/wvanders/pkgs/lib64" ":"
           (getenv "LD_LIBRARY_PATH"))))

;; Use MingW64 if available

(if (file-exists-p "C:\\msys64")
    (setenv "PATH"
            (concat
             "C:\\msys64\\usr\\bin" ";"
             "C:\\msys64\\mingw32\\bin" ";"
             "C:\\msys64\\mingw64\\bin" ";"
             (getenv "PATH"))))

;;;;;;;;;;;;;;;;;;;;;;;
;; Utility functions ;;
