- Python 2.7 or above
- Python 3.4 or above
- setuptools (pip/pip3 install setuptools)
- Informix client SDK 410xC2 or above
- Set environment variable CSDK_HOME and MY_PY_DIR
- Operating System Unicode encoding should match with your python interpreter encoding.
- setuptools
- pip
- wheel
- twine
You may need pip version version 10.0.1 or higher, if not upgrade
sudo apt update
#### For Python 3
# sudo apt install python3-pip
# python3 -m pip install --upgrade pip
# sudo python3 -m pip uninstall pip
pip3 install --upgrade pip
pip3 --version
##### if python 2.7
#sudo apt install python-pip
pip install --upgrade pip
pip --versionMY_PY_DIR points to the Python installation directory. During the driver build it need python header files, if the current Python installation doesn’t have the header file then you may need to get Python source code.
The python interpreter used should match with operating system default Unicode encoding. Some of the Linux flavors, python interpreter is available with UCS2/UTF16 and also UCS4/UTF32. If the OS default for Unicode is UTF32 then the OpenInformix driver will work if the python interpreter is also using the Unicode UCS4/UTF32.
>>> import sys
>>> print sys.maxunicode
### output
# if it is built with --enable-unicode=ucs4: then you will see
1114111
# if it is built with --enable-unicode=ucs2: then you will see
65535By any chance if you don’t have the right python interpreter or you don’t have the development environment for building native library then you may have to build python from its source. Python can be built from it source by using the following steps.
Determine the Unicode encoding needed for your python interpreter. Most of the Linux platforms are by default UCS4/UTF32, the following step is to build python for UCS4/UTF32 Unicode encoded string.
This instruction is for both Python 2.7 and Python 3.x build. The commented Python 3.x build instruction is good for building it from source.
cd /work/dev
rm ./Python
sudo rm -rf ./Python-2.7.13
wget https://www.python.org/ftp/python/2.7.14/Python-2.7.13.tgz
tar zxvf Python-2.7.13.tgz
ln -s ./Python-2.7.13 ./Python
cd /work/dev/Python
sudo ./configure --enable-unicode=ucs4Let us pick Python-3.7.1 for this
cd /work/dev
rm ./Python
sudo rm -rf ./Python-3.7.1
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
tar zxvf Python-3.7.1.tgz
ln -s ./Python-3.7.1 ./Python
cd /work/dev/Python
sudo ./configure --enable-unicode=ucs4cd /work/dev/Python
sudo ./configure --enable-unicode=ucs4
sudo make
sudo make installsudo pip install setuptools --upgrade
sudo pip install wheel --upgrade
sudo pip install twine --upgrade
pip install --upgrade pipsudo pip3 install setuptools --upgrade
sudo pip3 install wheel --upgrade
sudo pip3 install twine --upgrade
pip3 install --upgrade pipmkdir /work/t1
cd /work/t1
rm -rf /work/t1/IfxPy
git clone https://github.com/OpenInformix/IfxPy.git# sudo ln -s /home/informix/1210UC9 /work/informix
# Assuming 'CSDK' is installed at /work/informix
export CSDK_HOME=/work/informix
export MY_PY_DIR=/work/dev/Python
export PATH=/work/dev/Python:$PATHYou may choose one of the two build instructions to do the driver build. We recommend Wheel build.
- Driver build with wheel
- The legacy build
The wheel built package format includes these tags in its filenames, of the form
{distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}.whl.
Other package formats may have their own conventions.
The Python tag indicates the implementation and version required by a distribution. Major implementations have abbreviated codes, initially:
- py: Generic Python (does not require implementation-specific features)
- cp: CPython
- ip: IronPython
- pp: PyPy
- jy: Jython
The ABI tag indicates which Python ABI is required by any included extension modules. For implementation-specific ABIs, the implementation is abbreviated in the same way as the Python Tag, e.g. cp33d would be the CPython 3.3 ABI with debugging.
The platform tag is simply distutils.util.get_platform() with all hyphens - and periods . replaced with underscore
- win32
- linux_i386
- linux_x86_64
- manylinux1_x86_64
cd /work/t1/IfxPy/IfxPy
rm -rf /work/t1/IfxPy/IfxPy/build
rm -rf /work/t1/IfxPy/IfxPy/dist# Make sure you have installed wheel before doing the build
python setup.py bdist_wheel
# On successful build, it would have created the 'whl' file under '/work/t1/IfxPy/IfxPy/dist' folder.
ls -l /work/t1/IfxPy/IfxPy/dist# Make sure you have installed wheel before doing the build
python3 setup.py bdist_wheel --plat-name manylinux1_x86_64
# On successful build, it would have created the whl file under '/work/t1/IfxPy/IfxPy/dist' folder.
ls /work/t1/IfxPy/IfxPy/dist/IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whl
# FYI: to install the newly build driver binary on your system then
# pip3 install /work/t1/IfxPy/IfxPy/dist/IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whl
# pip3 uninstall /work/t1/IfxPy/IfxPy/dist/IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whl# Make sure you have installed wheel before doing the build
python setup.py bdist_wheel
# On successful build, it would have created the 'whl' file under '/work/t1/IfxPy/IfxPy/dist' folder.upload the driver binaries to PyPi
We have been using Wheel build to upload the binary. FYI: You need to have PiPy account and permission to upload the build binary
# make sure pip and wheel are upgradedfs
# pip2.7 install --upgrade --user travis pip setuptools wheel
# FYI: Example command to upload the build to PyPi
# the version information could be different on your build, make the adjustment
cd /work/t1/IfxPy/IfxPy/dist
twine upload IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whlFYI Only, we recommend wheel build mention above
cd /work/t1/IfxPy/IfxPy
rm -rf build
# '/work/dev/Python' has added to the path, then
# export PATH=/work/dev/Python:$PATH
# $ which python
# /work/dev/Python/python
# pip install setuptools
python setup.py build > out.txt 2>&1
#python3 setup.py build > out.txt 2>&1
# if all go well, then Informix native python driver will be at
# if Linux x86_64bit with Python 2.7 build then
ls -l ./build/lib.linux-x86_64-2.7/IfxPy.so
# if ARM v7 with Python 2.7 then
ls -l build/lib.linux-armv7l-2.7/IfxPy.so
# if Linux x86_64bit with Python 3.x build then
# ls -l ./build/lib.linux-x86_64-3.5/IfxPy.cpython-35m-x86_64-linux-gnu.so
# on armv7 with Python 3.x
# ls -l ls ./build/lib.linux-armv7l-3.5/IfxPy.cpython-35m-arm-linux-gnueabihf.soThe native lib is good enough to get advance features working. The Python Database API Specification v2.0 features are wrapper on top of the advance features that can be obtained by copying IfxPyDbi.py
# Copy Informix python package (IfxPy.so) to your Python module directory
# For example:
# Python 2.7 on linux-x86_64
cp /work/t1/IfxPy/IfxPy/build/lib.linux-x86_64-2.7/IfxPy.so .
# Python 2.7 ARMv7
# cp /work/t1/IfxPy/IfxPy/build/lib.linux-armv7l-2.7/IfxPy.so .
# Python 3.x on ARMv7
# cp /work/t1/IfxPy/IfxPy/build/lib.linux-armv7l-3.5/IfxPy.cpython-35m-arm-linux-gnueabihf.so ./IfxPy.so# You may use the whl file you have just built
sudo pip3 install /work/t1/IfxPy/IfxPy/dist/IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whl
# sudo pip3 uninstall /work/t1/IfxPy/IfxPy/dist/IfxPy-3.0.2-cp37-cp37m-manylinux1_x86_64.whlexport INFORMIXDIR=/work/informix
export LD_LIBRARY_PATH=${INFORMIXDIR}/lib:${INFORMIXDIR}/lib/esql:${INFORMIXDIR}/lib/cli
# Set the INFORMIXSQLHOSTS too, say
export INFORMIXSQLHOSTS=/work/dev/srv/ids0/sqlhostscd /work/try/
cp /work/t1/IfxPy/Examples/Sample1.py Sample.py
# Edit Sample.py connection information,
vi Sample.py
# and then run the sample
python Sample.py
# or if Pythong 3.x
python3 Sample.py