blob: ff394d685e17e2a164fa65ef1201b45d9d026a73 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/env bash
# Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "Linux/Cygwin environment" project.
# For details, see https://github.com/egor-tensin/linux-home.
# Distributed under the MIT License.
# This is a half-assed way to automatically add your user's pip binary
# directory to $PATH.
python_setup_() (
set -o errexit -o nounset -o pipefail
if [ "$#" -ne 1 ]; then
echo "usage: ${FUNCNAME[0]} PYTHON_EXE"
return 1
fi
local python="$1"
local user_base
user_base="$( "$python" -m site --user-base )"
local user_bin="$user_base/bin"
[ -d "$user_bin" ] || return 1
echo "$user_bin"
)
python_setup() {
local user_bin
if command -v python3 &> /dev/null; then
user_bin="$( python_setup_ python3 )" \
&& path_export "$user_bin"
elif command -v python &> /dev/null; then
user_bin="$( python_setup_ python )" \
&& path_export "$user_bin"
fi
}
python_setup
[ -r "$HOME/.pythonrc" ] && export PYTHONSTARTUP="$HOME/.pythonrc"
|