Thread: [cx-oracle-users] libclntsh.so and setup.py
Brought to you by:
atuining
From: Aurélien V. <val...@gm...> - 2012-02-09 09:26:33
|
Hello, Just a question, why does cx_Oracle lookup for libclntsh.so in $ORACLE_HOME and fail if not found? I have my libclntsh.so installed in /usr/local/lib, which means i basically need to export ORACLE_HOME=/usr/local pip install cx_Oracle export ORACLE_HOME=/usr/local/share/oracle11 Every time I need to install cx_Oracle - which is a pain since i need to deploy a alot of python applications needing cx_Oracle in virtualens. -- Aurélien Vallée +33 6 47 41 70 37 |
From: Ivanelson N. <iva...@gm...> - 2012-02-09 12:08:31
|
It really is very annoying to install cx_Oracle! Lately whenever I go I will install thisscript and have been successful. http://stackoverflow.com/a/8354852 Bye 2012/2/9 Aurélien Vallée <val...@gm...> > Hello, > > Just a question, why does cx_Oracle lookup for libclntsh.so in > $ORACLE_HOME and fail if not found? > I have my libclntsh.so installed in /usr/local/lib, which means i > basically need to > > export ORACLE_HOME=/usr/local > pip install cx_Oracle > export ORACLE_HOME=/usr/local/share/oracle11 > > Every time I need to install cx_Oracle - which is a pain since i need to > deploy a alot of python applications needing cx_Oracle in virtualens. > > -- > Aurélien Vallée > +33 6 47 41 70 37 > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > > |
From: Mark H. <mh...@pi...> - 2012-02-09 16:51:36
|
On 2/9/12 1:26 AM, Aurélien Vallée wrote: > Hello, > > Just a question, why does cx_Oracle lookup for libclntsh.so in $ORACLE_HOME and fail if not found? > I have my libclntsh.so installed in /usr/local/lib, which means i basically need to > > export ORACLE_HOME=/usr/local > pip install cx_Oracle > export ORACLE_HOME=/usr/local/share/oracle11 > > Every time I need to install cx_Oracle - which is a pain since i need to deploy a alot of python applications needing cx_Oracle in virtualens. We use the oracle instantclient on mac and linux (by your libclntsh.so filename, I'm guessing this may be linux?). We install like this: - all lib*.so to /usr/lib - all headers to /usr/include - sqlplus to /usr/bin - tnsnames.ora to /etc This will allow oracle clients to run nicely without setting any environment variables. Build cx_Oracle in this environment, and it will pick up the proper include files and libraries without problem. Hope this helps! Markk |
From: Mark H. <mh...@pi...> - 2012-02-09 16:58:45
|
On 2/9/12 8:51 AM, Mark Harrison wrote: > On 2/9/12 1:26 AM, Aurélien Vallée wrote: >> Hello, >> >> Just a question, why does cx_Oracle lookup for libclntsh.so in $ORACLE_HOME and fail if not found? >> I have my libclntsh.so installed in /usr/local/lib, which means i basically need to >> >> export ORACLE_HOME=/usr/local >> pip install cx_Oracle >> export ORACLE_HOME=/usr/local/share/oracle11 >> >> Every time I need to install cx_Oracle - which is a pain since i need to deploy a alot of python applications needing cx_Oracle in virtualens. > > We use the oracle instantclient on mac and linux (by your libclntsh.so filename, I'm > guessing this may be linux?). Oh, and I stuck this on Stackoverflow a while back for future reference: http://stackoverflow.com/questions/764871/installing-oracle-instantclient-on-linux-without-setting-environment-variables |
From: Aurélien V. <val...@gm...> - 2012-02-09 17:10:25
|
This cannot be used in my case. We have multiple configurations with their own oracle home! The standard linux/macosx way to look for libraries is to search the LD_LIBRARY_PATH, that is what cx_Oracle should use! On Thu, Feb 9, 2012 at 4:58 PM, Mark Harrison <mh...@pi...> wrote: > On 2/9/12 8:51 AM, Mark Harrison wrote: > > On 2/9/12 1:26 AM, Aurélien Vallée wrote: > >> Hello, > >> > >> Just a question, why does cx_Oracle lookup for libclntsh.so in > $ORACLE_HOME and fail if not found? > >> I have my libclntsh.so installed in /usr/local/lib, which means i > basically need to > >> > >> export ORACLE_HOME=/usr/local > >> pip install cx_Oracle > >> export ORACLE_HOME=/usr/local/share/oracle11 > >> > >> Every time I need to install cx_Oracle - which is a pain since i need > to deploy a alot of python applications needing cx_Oracle in virtualens. > > > > We use the oracle instantclient on mac and linux (by your libclntsh.so > filename, I'm > > guessing this may be linux?). > > Oh, and I stuck this on Stackoverflow a while back for future reference: > > > http://stackoverflow.com/questions/764871/installing-oracle-instantclient-on-linux-without-setting-environment-variables > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > -- Aurélien Vallée +33 6 47 41 70 37 |
From: Lassi T. <la...@ce...> - 2012-02-09 18:33:11
|
Hi, > The standard linux/macosx way to look for libraries is to search the LD_LIBRARY_PATH, that is what cx_Oracle should use! We build py2-cx-oracle RPMs using setup.cfg, with the following sort of thing. This is a bit of a short-hand skeleton which our RPM builder expands to the real spec file, but the following should be the relevant bits. $ORACLE_ROOT is where we put our instant client, the headers are under 'include' and libraries under 'lib'. At the build time, $PATH, $LD_LIBRARY_PATH etc have been set so they include instant client directories (and python, and all other externals we use). %i is where we install into. I'm actually pretty happy cx-oracle does *not* go poking around the system trying to find things, but instead lets us specify where to find things. It's a bonus if it fails hard if things aren't where we think they should be, so the configuration is guaranteed to be consistent. %prep %setup -n cx_Oracle-5.1 %patch -p1 cat >> setup.cfg <<- EOF [build_ext] include_dirs = $ORACLE_ROOT/include library_dirs = $ORACLE_ROOT/lib EOF %build python setup.py build %install python setup.py install --prefix=%i Regards, Lassi |
From: Aurélien V. <val...@gm...> - 2012-02-09 20:37:26
|
Hello Lassi, I am still not satisfied with your explanation. I'm actually pretty happy cx-oracle does *not* go poking around the system > trying to find things, but instead lets us specify where to find things. This is *not *"poking around the system", this is a standard convention on unix platforms... Every single build tool out there use the same set of environment variables to look for libraries and include files. LD_LIBRARY_PATH is made for this task: it lets you specify the path that contains your shared libraries, i can't imagine any reason for cx_Oracle to use its own hardcoded convention! Even the Oracle instant client documentation states it: Set your OS's library search path to point to the installed location. OS Environment > Variable Name Linux LD_LIBRARY_PATH If you installed libclntsh.so in $ORACLE_HOME/lib, then just export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib and cx_Oracle will find it. If you installed it system wide (/usr/local/lib), then it is already in your LD_LIBRARY_PATH. In fact, the unix "de facto" way of checking for the presence of a library is even try harder than looking in LD_LIBRARY_PATH. Autoconf and CMake for instance just try to compile and link a dummy hello world against the library. This has the advantage of taking into account shared libraries directories specified via LDFLAGS="-L..." and include directories specified via C_INCLUDE_PATH / CPLUS_INCLUDE_PATH or CFLAGS="-I...". Again, this is all just standard unix conventions, and dealing with weird behaviors such as cx_Oracle's madatory $ORACLE_HOME/lib/libclntsh.so does is a real pain. Just have a look at how pyzmq (zeromq python bindings) handles this. On Thu, Feb 9, 2012 at 7:32 PM, Lassi Tuura <la...@ce...> wrote: > Hi, > > > The standard linux/macosx way to look for libraries is to search the > LD_LIBRARY_PATH, that is what cx_Oracle should use! > > We build py2-cx-oracle RPMs using setup.cfg, with the following sort of > thing. This is a bit of a short-hand skeleton which our RPM builder expands > to the real spec file, but the following should be the relevant bits. > $ORACLE_ROOT is where we put our instant client, the headers are under > 'include' and libraries under 'lib'. At the build time, $PATH, > $LD_LIBRARY_PATH etc have been set so they include instant client > directories (and python, and all other externals we use). %i is where we > install into. > > I'm actually pretty happy cx-oracle does *not* go poking around the system > trying to find things, but instead lets us specify where to find things. > It's a bonus if it fails hard if things aren't where we think they should > be, so the configuration is guaranteed to be consistent. > > > %prep > %setup -n cx_Oracle-5.1 > %patch -p1 > > cat >> setup.cfg <<- EOF > [build_ext] > include_dirs = $ORACLE_ROOT/include > library_dirs = $ORACLE_ROOT/lib > EOF > > %build > python setup.py build > > %install > python setup.py install --prefix=%i > > Regards, > Lassi > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > -- Aurélien Vallée +33 6 47 41 70 37 |
From: Lassi T. <la...@ce...> - 2012-02-09 21:13:55
|
Hi, > I am still not satisfied with your explanation. Sorry, I wasn't trying to explain or justify cx_oracle's behaviour. I'm basically just a satisfied user. We like how it works - I appreciate someone else might like it another way, and it seems you do. I'm far from an expert on python packaging, but setting preferred path locations via setup.cfg seems quite commonplace for python packages. In our distribution build environment, it works well, but I rather suspect our requirements differ from yours. Regards, Lassi |
From: Mark H. <mh...@pi...> - 2012-02-09 22:29:49
|
On 2/9/12 1:13 PM, Lassi Tuura wrote: > Hi, > >> I am still not satisfied with your explanation. > > Sorry, I wasn't trying to explain or justify cx_oracle's behaviour. I'm basically just a satisfied user. We like how it works - I appreciate someone else might like it another way, and it seems you do. I'm far from an expert on python packaging, but setting preferred path locations via setup.cfg seems quite commonplace for python packages. In our distribution build environment, it works well, but I rather suspect our requirements differ from yours. Having messed with configure.in scripts before and trying to deal with all the unix variants, I'd just like to point out that Anthony has done an amazing job of getting things to build on multiple platforms, different versions of oracle, and many different types of oracle installations. Thanks Anthony! |
From: Aurélien V. <val...@gm...> - 2012-02-09 23:15:48
|
Not a matter of taste, it's a matter of "standard expected way", or "weird uncommon way". Using LD_LIBRARY_PATH would not change a lot to people using the current behavior (just add $ORACLE_HOME/lib to your LD_LIBRARY_PATH) and would help a lot those trying to manage uniform python packages. Furthermore, setup.cfg is nice, but does not play well with pip... On Thu, Feb 9, 2012 at 11:29 PM, Mark Harrison <mh...@pi...> wrote: > On 2/9/12 1:13 PM, Lassi Tuura wrote: > > Hi, > > > >> I am still not satisfied with your explanation. > > > > Sorry, I wasn't trying to explain or justify cx_oracle's behaviour. I'm > basically just a satisfied user. We like how it works - I appreciate > someone else might like it another way, and it seems you do. I'm far from > an expert on python packaging, but setting preferred path locations via > setup.cfg seems quite commonplace for python packages. In our distribution > build environment, it works well, but I rather suspect our requirements > differ from yours. > > Having messed with configure.in scripts before and trying to deal with all > the unix variants, I'd just like to point out that Anthony has done an > amazing job of getting things to build on multiple platforms, different > versions of oracle, and many different types of oracle installations. > > Thanks Anthony! > > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > -- Aurélien Vallée +33 6 47 41 70 37 |
From: Mark H. <mh...@pi...> - 2012-02-09 23:52:34
|
On 2/9/12 3:15 PM, Aurélien Vallée wrote: > Not a matter of taste, it's a matter of "standard expected way", or "weird uncommon way". Using LD_LIBRARY_PATH would not change a lot to people using the current behavior (just add $ORACLE_HOME/lib to your LD_LIBRARY_PATH) and would help a lot those trying to manage uniform python packages. I think part of the problem is that cx_Oracle needs to find the OCI include files as well as the libraries. Create a patch for the configure script and submit it to Anthony... we'll all benefit from your work! Just make sure it doesn't break existing users if you can help it. Good Luck! |
From: Anthony T. <ant...@gm...> - 2012-02-12 05:37:20
|
2012/2/9 Aurélien Vallée <val...@gm...>: > Not a matter of taste, it's a matter of "standard expected way", or "weird > uncommon way". Using LD_LIBRARY_PATH would not change a lot to people using > the current behavior (just add $ORACLE_HOME/lib to your LD_LIBRARY_PATH) and > would help a lot those trying to manage uniform python packages. Ok. Let me see if I can clear things up for you. :-) First of all, Oracle is used on a lot of platforms and so LD_LIBRARY_PATH is not something used on all of them. They came up with a different environment variable ORACLE_HOME that is used or (on Windows) they simply use the PATH environment variable. So for Oracle, what you are suggesting is not "the standard expected way!" Regardless, the paths searched for libraries generally includes LD_LIBRARY_PATH and the setup.py for cx_Oracle does nothing to prevent such linking from happening. The logic that is used in the setup.py should be okay. 1) attempt to find what ORACLE_HOME directory should be used by looking at the environment variable (if specified) or searching the PATH environment variable 2) For each directory, attempt to find the DLL or shared library in $ORACLE_HOME or certain subdirectories which are dependent on platform. The file name searched for will be something like libclntsh.so.11.1 and it is assumed that a symbolic link will be found in that directory called libclntsh.so as otherwise the linking will fail. 3) Once found, set the library directories to search to include the directory in which the libclntsh.so file was found and set the include directories to search based on what a normal Oracle installation looks like Note there are a few scenarios that are covered 1) Full installation with subdirectories bin and lib as standard 2) Instant client all in one directory 3) Instant client similar to full installation with subdirectories bin and lib as standard If you can let me know what your situation is like and why it is not covered by this logic I'd be happy to make adjustments -- but so far you have not given us many details. Can you perhaps show us the directory structure you have, what you have for LD_LIBRARY_PATH, PATH and ORACLE_HOME and what you expect to happen? Thanks. Anthony |
From: D.R. B. <da...@as...> - 2012-02-10 10:56:39
|
Hello Aurélien, My apologies in advance if I misinterpret your question, but cx_Oracle only uses ORACLE_HOME to find the Oracle sdk for the include files when you compile cx_Oracle. If we look at the source code of cx_Oracle we'll see there is no reference to ORACLE_HOME at all. Perhaps you mean that cx_Oracle does not look at LD_LIBRARY_PATH when you import the module from python. On all the platforms I have tried LD_LIBRARY_PATH is used, however, so I am wondering what platform you use or what else is going on. In any case, after cx_Oracle has been built ORACLE_HOME does not have to be defined, which is what you seem to suggest in your example. Salut, Danny 2012/2/9 Aurélien Vallée <val...@gm...>: > Hello, > > Just a question, why does cx_Oracle lookup for libclntsh.so in $ORACLE_HOME > and fail if not found? > I have my libclntsh.so installed in /usr/local/lib, which means i basically > need to > > export ORACLE_HOME=/usr/local > pip install cx_Oracle > export ORACLE_HOME=/usr/local/share/oracle11 > > Every time I need to install cx_Oracle - which is a pain since i need to > deploy a alot of python applications needing cx_Oracle in virtualens. > > -- > Aurélien Vallée > +33 6 47 41 70 37 > > ------------------------------------------------------------------------------ > Virtualization & Cloud Management Using Capacity Planning > Cloud computing makes use of virtualization - but cloud computing > also focuses on allowing computing to be delivered as a service. > http://www.accelacomm.com/jaw/sfnl/114/51521223/ > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |