Skip to content

Instantly share code, notes, and snippets.

@davecoutts
Last active April 2, 2018 12:47
Show Gist options
  • Save davecoutts/682c21135ea6edd91a51366e18b29451 to your computer and use it in GitHub Desktop.
Save davecoutts/682c21135ea6edd91a51366e18b29451 to your computer and use it in GitHub Desktop.
Build Python 3.5 conda package for cx_oracle 5.2.1 on Linux
# Build Python 3.5 conda package for cx_oracle 5.2.1 on Linux
# Currently(2016-07-09) only cx_oracle-5.1.2-py27 is avalible in the conda repository.
#
# Based on http://conda.pydata.org/docs/build_tutorials/pkgs.html
#
# Build environment: Ubuntu 16.04 with Anaconda3-4.1.1-Linux-x86_64 installed in $HOME/anaconda3
#
# Download from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
# - instantclient-basic-linux.x64-12.1.0.2.0.zip
# - instantclient-sdk-linux.x64-12.1.0.2.0.zip
sudo apt-get -y update
sudo apt-get -y install python3-dev build-essential libaio1 unzip
conda upgrade conda-build
mkdir -p /tmp/cx_oracle_build
unzip $HOME/Downloads/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /tmp/cx_oracle_build
unzip $HOME/Downloads/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /tmp/cx_oracle_build
ln -s /tmp/cx_oracle_build/instantclient_12_1/libclntsh.so.12.1 /tmp/cx_oracle_build/instantclient_12_1/libclntsh.so
export ORACLE_HOME=/tmp/cx_oracle_build/instantclient_12_1
export LD_LIBRARY_PATH=/tmp/cx_oracle_build/instantclient_12_1
cd /tmp/cx_oracle_build
conda skeleton pypi cx_oracle --version 5.2.1
echo "build:
script_env:
- ORACLE_HOME
- LD_LIBRARY_PATH" | tee -a /tmp/cx_oracle_build/cx_oracle/meta.yaml
#cat /tmp/cx_oracle_build/cx_Oracle/meta.yaml
conda build cx_oracle
ls -lh $HOME/anaconda3/conda-bld/linux-64/cx_oracle-5.2.1-py35_0.tar.bz2
conda install --use-local --yes cx_oracle
conda list oracle
# Clean up
rm $HOME/Downloads/instantclient-*.zip
rm -rf /tmp/cx_oracle_build
conda clean --all --yes
python -c "import cx_Oracle; print(cx_Oracle.__version__)"
@borje
Copy link

borje commented Nov 25, 2016

Did you have to set LD_LIBRARY_PATH to make this work? When "import cx_Oracle" is executed, I get the following error message
"ImportError: libclntsh.so.12.1: cannot open shared object file: No such file or directory"

Isn't conda supposed to make the package relocateable. This should be possible to solve without setting LD_LIBRARY_PATH, right?

@davecoutts
Copy link
Author

I see that cx_oracle is now available with anaconda https://anaconda.org/anaconda/cx_oracle .
I recommend that you don't use this gist. Go for the official package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment