Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove f dependency #57

Merged
merged 3 commits into from
Jan 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pipenv.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; Author: Paul Walsh <paulywalsh@gmail.com>
;; URL: https://github.com/pwalsh/pipenv.el
;; Version: 0.0.1-beta
;; Package-Requires: ((emacs "25.1") (f "0.19.0") (s "1.12.0") (pyvenv "1.20"))
;; Package-Requires: ((emacs "25.1") (s "1.12.0") (pyvenv "1.20"))

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand All @@ -26,7 +26,6 @@

;;; Code:

(require 'f)
(require 'python)
(require 's)
(require 'subr-x)
Expand Down Expand Up @@ -139,7 +138,7 @@
"Filter for PROCESS, which sets several global variables based on RESPONSE."
(when (and
(s-equals? (nth 0 (last (process-command process))) "--venv")
(f-directory? response))
(file-directory-p response))
(setq python-shell-virtualenv-root response)))

(defun pipenv--process-filter (process response)
Expand All @@ -151,7 +150,7 @@
(defun pipenv--get-executables-dir ()
"Get the directory of executables in an active virtual environment, or nil."
(when (and python-shell-virtualenv-root
(f-directory? python-shell-virtualenv-root))
(file-directory-p python-shell-virtualenv-root))
(concat
(file-name-as-directory python-shell-virtualenv-root)
(if (eq system-type 'windows-nt) "Scripts" "bin"))))
Expand All @@ -174,6 +173,14 @@
(sentinel 'pipenv--messaging-sentinel))
(pipenv--make-pipenv-process command filter sentinel)))

(defun pipenv--f-parent (path)
"Return the parent directory to PATH. see `f-parent'."
(let ((parent (file-name-directory
(directory-file-name (f-expand path default-directory)))))
(if (file-name-absolute-p path)
(directory-file-name parent)
(file-relative-name parent))))

;;
;; Interactive commands that implement the Pipenv interface in Emacs.
;;
Expand Down Expand Up @@ -273,7 +280,7 @@ or (if none is given), installs all packages."
(s-trim)
(s-replace-all replacements)))
(ideal-path (if (s-contains? suffix real-path)
(f-dirname real-path)
(pipenv--f-parent real-path)
real-path)))
(find-file ideal-path)))

Expand Down