;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\207" [require cl-lib nadvice] 2) #@231 Venv directory path. This variable is intended to be explicitly set by user. When nil, `with-venv' tries to find suitable venv dir. When this variable is set , use this value without checking if it is a valid python environment. (defvar with-venv-venv-dir nil (#$ . 156)) (make-variable-buffer-local 'with-venv-venv-dir) #@173 Set python environment to DIR and execute BODY. This macro does not check if DIR is a valid python environemnt. If dir is nil, execute BODY as usual. (fn DIR &rest BODY) (defalias 'with-venv-dir '(macro . #[385 "\300\301\302\303\304\305\306\307\nDD\310B\311BBEBB\312BBE\207" [let ((--with-venv-process-environment-orig (cl-copy-list process-environment)) (--with-venv-exec-path-orig (cl-copy-list exec-path))) unwind-protect progn when let* dir file-name-as-directory ((bin (expand-file-name "bin" dir))) ((setq exec-path (cons bin exec-path)) (setenv "VIRTUAL_ENV" dir) (setenv "PATH" (concat bin ":" (or (getenv "PATH") ""))) (setenv "PYTHONHOME")) ((setq process-environment --with-venv-process-environment-orig) (setq exec-path --with-venv-exec-path-orig))] 12 (#$ . 485)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put with-venv-dir lisp-indent-function 1 put edebug-form-spec t] 5) #@32 Previously used venv dir path. (defvar with-venv-previously-used nil (#$ . 1406)) (make-variable-buffer-local 'with-venv-previously-used) #@159 Execute BODY with venv enabled. This function tries to find suitable venv dir, or run BODY as usual when no suitable environment was found. (fn &rest BODY) (defalias 'with-venv '(macro . #[128 "\300\301BB\207" [with-venv-dir (or with-venv-venv-dir (with-venv-check-exists with-venv-previously-used) (setq with-venv-previously-used (with-venv-find-venv-dir)))] 4 (#$ . 1551)])) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put with-venv lisp-indent-function 0 put edebug-form-spec t] 5) #@77 Try to find venv dir for DIR. If none found return nil. (fn &optional DIR) (defalias 'with-venv-find-venv-dir #[256 "\300\301\302\"r\211q\210\303\304\"\216\203\305!\210\306\307 !\206'\306\310 !\206'\306\311 !*\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] cd with-venv-check-exists with-venv--find-venv-dir-pipenv with-venv--find-venv-dir-poetry with-venv--find-venv-dir-by-name] 5 (#$ . 2063)]) #@34 Try to find venv dir via pipenv. (defalias 'with-venv--find-venv-dir-pipenv #[0 "\300\301\302\"r\211q\210\303\304\"\216\305\306\307\302\307\310%\211\311=\205#eb\210\312\313 \314 \"\262*\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] call-process "pipenv" nil "--venv" 0 buffer-substring-no-properties point-at-bol point-at-eol] 7 (#$ . 2545)]) #@34 Try to find venv dir via poetry. (defalias 'with-venv--find-venv-dir-poetry #[0 "\300\301\302\"r\211q\210\303\304\"\216\305\306\307\302\307\310%\211\311=\2050eb\210\312 \303\313\"\216\314\315!\205-\316\317!)\262\262*\207" [generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] call-process "poetry" nil "debug:info" 0 match-data #[0 "\301\300\302\"\207" [V0 set-match-data evaporate] 3] re-search-forward "^ \\* Path: *\\(.*\\)$" match-string 1] 7 (#$ . 2969)]) #@35 Try to find venv dir by its name. (defalias 'with-venv--find-venv-dir-by-name #[0 "\301\302\"\211\205\f\303\302\"\207" [default-directory locate-dominating-file ".venv" expand-file-name] 4 (#$ . 3501)]) #@68 Return DIR as is if "bin" directory was found under DIR. (fn DIR) (defalias 'with-venv-check-exists #[257 "\211\205\300\301\302\"!\205\211\207" [file-directory-p expand-file-name "bin"] 5 (#$ . 3713)]) #@75 Setup advice so that FUNC use `with-env' macro when executing. (fn FUNC) (defalias 'with-venv-advice-add #[257 "\300\301\302#\207" [advice-add :around with-venv--advice-around] 5 (#$ . 3927)]) #@64 Remove advice FUNC added by `with-venv-advice-add'. (fn FUNC) (defalias 'with-venv-advice-remove #[257 "\300\301\"\207" [advice-remove with-venv--advice-around] 4 (#$ . 4128)]) #@256 Function to be used to advice functions with `with-venv-advice-add'. When a function is adviced with this function, it is wrapped with `with-venv'. ORIG-FUNC is the target function, and ARGS is the argument when it was called. (fn ORIG-FUNC &rest ARGS) (defalias 'with-venv--advice-around #[385 "\304!\304 !\305\306#\216\n\204\307 !\204\310 \211\203M\311\n\206,\307 !\206,\310 \211!\312\313\"\211 B\314\315\"\210\314\316\317\320\316!\206E\321Q\"\210\314\322!\266\323\")\207" [process-environment exec-path with-venv-venv-dir with-venv-previously-used cl-copy-list make-closure #[0 "\300\301\211\207" [V0 V1 process-environment exec-path] 2] with-venv-check-exists with-venv-find-venv-dir file-name-as-directory expand-file-name "bin" setenv "VIRTUAL_ENV" "PATH" ":" getenv "" "PYTHONHOME" apply] 12 (#$ . 4314)]) (provide 'with-venv)