Skip to content

Commit 9847d48

Browse files
committed
ENH: use shutil.which() instead of external which(1)
Use the `shutil.which()` function to determine whether executables exist rather than calling the external `which(1)` or `where` program. This program is not a part of POSIX base system, and modern Linux distributions are working towards making it completely optional. The builtin `shutil.which()` is available since Python 3.3 and already used in the same file. This makes it possible to remove the dependency on `sys-apps/which` from Gentoo systems.
1 parent ac8d34d commit 9847d48

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

pandas/io/clipboard/__init__.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,9 @@
7979

8080
ENCODING = "utf-8"
8181

82-
# The "which" unix command finds where a command is.
83-
if platform.system() == "Windows":
84-
WHICH_CMD = "where"
85-
else:
86-
WHICH_CMD = "which"
87-
8882

8983
def _executable_exists(name):
90-
return (
91-
subprocess.call(
92-
[WHICH_CMD, name], stdout=subprocess.PIPE, stderr=subprocess.PIPE
93-
)
94-
== 0
95-
)
84+
return which(name) is not None
9685

9786

9887
def _stringifyText(text) -> str:

0 commit comments

Comments
 (0)