-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpython.al
More file actions
90 lines (78 loc) · 2.16 KB
/
python.al
File metadata and controls
90 lines (78 loc) · 2.16 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
## Function list
#
## TODO
##
# TODO:
# - create virtual env (for python 3 and 2)
i-pip(){
url='https://bootstrap.pypa.io/get-pip.py'
if [ -z $1 ]; then
curl $url | python
else
curl $url | sudo python
fi
}
# python virtual environment (docker boot-stratpped)
pyenv(){
if [ ! -e ./venv ]; then
if [[ $1 == "2" ]]; then
dripf python:2 virtualenv ./venv
else
dripf python:3 python3 -m venv ./venv
fi
fi
source "venv/bin/activate"
}
pyenvd(){ deactivate ;}
pyenvdd(){ rm -rf venv ;}
ppi(){ pip install -r requirements.txt ;}
ppf(){ pip freeze > requirements.txt ;}
pydir(){ touch __init__.py ;}
# TODO pip dep-tree
# pipdeptree
mkpimodule(){
mkdir $1
touch $1/__init__.py
}
# python build
#pb(){ python setup.py sdist ;}
pb(){ python setup.py sdist bdist_wheel ;}
## JAVA ##
alias jar-list='jar tvf'
pypackinstall(){
pip install --editable .
}
py3install(){
python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel
}
pyscratchtest(){ python -m unittest test.scratch.Scratch ;}
pytest(){ python -m unittest ${@:1} ;}
pyinttest(){ python -m unittest discover -p *int_test.py ${@:1} ;}
pye2etest(){ python -m unittest discover --failfast -p *e2e_test.py ${@:1} ;}
pymantest(){ python -m unittest discover --failfast -p *man_test.py ${@:1} ;}
i-python(){
## builds and installs python 3+ from source
# NOTE: requires - gcc zlib-devel openssl-devel bzip2-devel libffi-devel
# TODO: make configurable
major=3
minor=7
patch=5
version=${major}.${minor}.${patch}
fname=Python-${version}
tname=${fname}.tgz
dname=python${major}.${minor}
lname=python${major}
curl -O https://www.python.org/ftp/python/${version}/${tname}
tar -xzvf ${tname}
cd ${fname}
./configure --prefix=/usr/local/${dname} --enable-optimizations
make && make install
ln -s /usr/local/${dname}/bin/${dname} /usr/bin/${lname}
ln -s /usr/local/${dname}/bin/${dname} /usr/bin/${lname}${minor}
ln -s /usr/local/${dname}/bin/pip /usr/bin/pip
ln -s /usr/local/${dname}/bin/pip3 /usr/bin/pip3
# ln -s /usr/local/${dname}/bin /usr/bin/ppython
# echo 'PATH=$PATH:/usr/bin/ppython' > /etc/profile.d/ppython.sh
}