Python 2.7.9 and pip commands

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

#Compiling python-2.7.9
NEW_BUILD_NAME=python
NEW_BUILD_VER=2.7.9
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

#ERROR
	Failed to build these modules:
	_curses_panel      readline
#SOLUTION (before configure)
	use -lreadline -lncurses for BUILD_FLAGS and LDFLAGS
#./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl --with-ensurepip=upgrade
#configure without pip; better install manually pip-6.0.6 in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip
./configure --prefix=/ffp --enable-shared --enable-ipv6 --enable-big-digits --enable-unicode --with-signal-module --with-threads=/ffp --with-pth --with-doc-strings --without-pymalloc --with-fpectl
#ERROR
	./Parser/asdl_c.py -h Include ./Parser/Python.asdl
	/ram_bin/usr/bin/python: /ffp/lib/libpthread.so.0: no version information available (required by /usr/lib/libpython2.6.so.1.0)
	make: *** [Include/Python-ast.h] Segmentation fault (core dumped)
#SOLUTION (before make)
	touch Include/Python-ast.h Python/Python-ast.c
#ERROR
	Failed to build these modules:
	_curses_panel
#SOLUTION (before make)
	slacker -u br2:ncurses-5.9_20140927-arm-1.txz
renice -14 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof configure`
#grep -I -r "\/bin" . | grep -v "\/ffp\/bin" | grep -v "\/ffp\/sbin"
sed -i s/"\/bin\/install"/"\/ffp\/bin\/install"/g Makefile
sed -i s/"\/bin\/install"/"\/ffp\/bin\/install"/g Makefile.pre
touch Include/Python-ast.h Python/Python-ast.c
nohup /ffp/bin/make -C ~/compile/Python-2.7.9 &
tail -f nohup.out
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz
#In order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)
#download the Mozilla's CA Bundle certificate:
wget -nv http://curl.haxx.se/ca/cacert.pem -O /ffp/etc/ssl/cert.pem

#You could use easy_install (from setuptools module) in order to install modules as alternative to pip.
#When using pip if required to use --egg option than better compile the module manually.
#see http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309

#List python modules:
python
#then, from python's shell/prompt:
help('modules')
help('setuptools') -> info about setuptools module
help('jinja2') -> info about jinja2 module (observe lower case usage)

#List module's files
pip show -f Jinja2

#Install pip 6.0.6 (a tool for installing and managing Python packages)
#pip 6.0.6 has no CERTIFICATE_VERIFY_FAILED error
#requires scripttest (>=1.3) and virtualenv (>=1.10)
#wget https://pypi.python.org/packages/source/s/scripttest/scripttest-1.3.tar.gz
#wget https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.5.tar.gz#md5=637abbbd04d270ee8c601ab29c4f7561
cd ~/compile
wget https://pypi.python.org/packages/source/p/pip/pip-6.0.6.tar.gz#md5=bbb17814bdf82187f46aaf9cec6b6caa
tar xvzf pip-6.0.6.tar.gz
cd pip-6.0.6
~/x.sh ffpg
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -fno-stack-protector -pthread -O2 -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Uninstall a python module
cd ~/compile/pip-1.2.1 -> has CERTIFICATE_VERIFY_FAILED error at install
cd ~/compile/pip-1.5.6 -> has CERTIFICATE_VERIFY_FAILED error always
cd ~/compile/pip-6.0.6 -> has no CERTIFICATE_VERIFY_FAILED error
cat module-files.txt | xargs rm -rf
find /ffp/lib/python2.7/ -name "*pip*"
rm -r /ffp/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg

#Install Jinja2-2.7.3
cd ~/compile
wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
tar xvzf Jinja2-2.7.3.tar.gz
cd Jinja2-2.7.3
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install SCons (better compile manually SCons because its files have non-FFP paths)
#SCons install doesn't work without --egg option.
#see also http://forum.nas-central.org/viewtopic.php?f=249&t=16627&p=92309#p92309
pip install -U setuptools
pip install SCons -vvv --egg --log /ffp/var/log/python/SCons.txt
#Modify the paths used by /ffp/bin/scons* files.

#Using pip:
python -m pip help
python -m pip list
#varianta cu freeze e o listare care arata si eventualele probleme ale pachetelor
python -m pip freeze
python -m pip help install
python -m pip search simplejson
python -m pip install simplejson -> nu a functionat
python -m pip install cryptography 0.6.1
python -m pip install pyOpenSSL 0.14 -vvv --log /ffp/var/log/python/pyOpenSSL-0.14.txt
python -m pip list --outdated
python -m pip install -U CherryPy -> updating CherryPy
python -m pip uninstall pycurl
python -m pip install rst2html5 -> required by aria2
pip install PIL --allow-unverified PIL

#ERROR (la instalarea multor pachete)
	AttributeError: Distribution instance has no attribute 'include_package_data'
#SOLUTION
	Nu instala setuptools folosind:
	wget https://bitbucket.org/pypa/setuptools/get/default.tar.gz#egg=setuptools-dev

#Install setuptools 7.0
cd ~/compile
#wget imediat urmator va crapa dar va afisa wget pt descarcarea setuptools 7.0 ce functioneaza corect:
#wget https://bootstrap.pypa.io/ez_setup.py -O - | python
#setuptools 7.0 ce functioneaza corect:
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.zip
mv default.tar.gz setuptools-7.0.tar.gz
cd pypa-setuptools-48a23a037ea2/
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
python setup.py --help build
python setup.py build
python setup.py install --record module-files.txt

#Install pycurl-7.19.5 -> required by pyLoad and easier to install using pip or easy_install (from setuptools)
cd ~/compile
wget http://pycurl.sourceforge.net/download/pycurl-7.19.5.tar.gz
tar xvzf pycurl-7.19.5.tar.gz
cd pycurl-7.19.5
find . -type f \( -exec sed -i s/"\/usr\/bin\/perl"/"\/ffp\/bin\/perl"/ {} \; , -exec sed -i s/"\/usr\/bin\/python"/"\/ffp\/bin\/python"/ {} \; , -exec sed -i s/"\/usr\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/usr\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/usr\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/bin\/bash"/"\/ffp\/bin\/bash"/ {} \; , -exec sed -i s/"\/bin\/sh"/"\/ffp\/bin\/sh"/ {} \; , -exec sed -i s/"\/bin\/env"/"\/ffp\/bin\/env"/ {} \; , -exec sed -i s/"\/ffp\/ffp\/"/"\/ffp\/"/ {} \; \)
export BUILD_FLAGS="-march=armv5te -mfloat-abi=soft -mabi=aapcs-linux -pthread -O2 -lintl -Wall -I/ffp/include"
export LDFLAGS="-L/ffp/lib -lintl"
export CPPFLAGS="$BUILD_FLAGS"
export CXXFLAGS="$BUILD_FLAGS"
export CFLAGS="$BUILD_FLAGS"
export LC_ALL=POSIX
python setup.py --help-commands
python setup.py --help
#ERROR0
	python: symbol 'CRYPTO_set_locking_callback': can't resolve symbol
	python: symbol 'CRYPTO_num_locks': can't resolve symbol
	python: symbol 'CRYPTO_set_id_callback': can't resolve symbol
	Traceback (most recent call last):
	File "<stdin>", line 1, in <module>
	ImportError: unknown dlopen() error
#SOLUTION0
	Nu compila cu openssl:
	python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl --openssl-dir=/ffp
	Modifica setup.py:
	# self.libraries = []
	self.libraries = ["crypto"]
python setup.py build --curl-config=/ffp/bin/curl-config --with-ssl
python setup.py install --record module-files.txt
#test installation:
python
import pycurl
CTRL+D

#certifi (14.5.14)	-> required in order to avoid CERTIFICATE_VERIFY_FAILED when using easy_install (from setuptools)
#pip (6.0.6)		-> required version in order to avoid CERTIFICATE_VERIFY_FAILED error when running pip

#Requirements files are used to hold the result from pip freeze for the purpose of achieving repeatable installations. 
#In this case, your requirement file contains a pinned version of everything that was installed when pip freeze was run.
pip freeze > /ffp/opt/apache-htdocs/public/python2.7-packages.txt
pip install -r /ffp/opt/apache-htdocs/public/python2.7-packages.txt

#ecdsa module below must be corrected after installation:
cd /ffp/lib/python2.7/site-packages/ecdsa
ffpg

#root@nsa310:~# pip list
certifi (14.5.14)
CherryPy (3.2.6)
ecdsa (0.12)
iotop (0.6)
Jinja2 (2.7.3)
libxml2-python (2.6.21)
lxml (3.4.2)
MarkupSafe (0.23)
mod-python (3.5.0-)
nose (1.3.4)
paramiko (1.15.2)
pip (6.0.6)
pycrypto (2.6.1)
pycurl (7.19.5.1)
pykg-config (1.3.0)
Pyrex (0.9.9)
pysqlite (2.6.3)
pytesseract (0.1.5)
pytz (2014.10)
setuptools (12.0.4)
tzselect (0.1)
WebHelpers (1.3)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.