gocept.cxoracle - A zc.buildout recipe to easily get cx_Oracle running
An example buildout might look like this:
[buildout] develop = . parts = python-oracle cx_Oracle test python = python-oracle [python-oracle] recipe = gocept.cxoracle instant-client = .../instantclient-basiclite-macosx-10.2.0.4.0.zip instant-sdk = .../instantclient-sdk-macosx-10.2.0.4.0.zip [cx_Oracle] recipe = zc.recipe.egg:custom egg = cx_Oracle [test] recipe = zc.recipe.testrunner eggs = test.some.egg
gocept.cxoracle - A zc.buildout recipe to easily get cx_Oracle running
The main purpose is to set up the environment required to build a cx_Oracle egg and then provide a loader which sets environment variables required to load the shared libraries.
Oracle doesn’t allow the libraries required to be distributed freely. That means that they must be downloaded by the user or developer from http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
Two archives are required per architecture / operating system:
Instant client basic lite
The SDK
>>> import os.path >>> basiclite = os.path.join( ... os.path.dirname(__file__), 'basiclite-linux.zip') >>> sdk = os.path.join( ... os.path.dirname(__file__), 'sdk-linux.zip')
Both files have to be configured in the buildout:
>>> write("buildout.cfg", """
... [buildout]
... parts = python-oracle
... python = python-oracle
...
... [python-oracle]
... recipe = gocept.cxoracle
... instant-client = %(basiclite)s
... instant-sdk = %(sdk)s
...
... """ % {'basiclite': basiclite,
... 'sdk': sdk}
... )
>>> print system(buildout), Installing python-oracle.
We have an oracle-home now in the parts. It contains the contents of both archives mixed together plus a symlink for libclntsh.so -> libclntsh.so.10.1:
>>> ls('parts', 'python-oracle')
- BASIC_LITE_README
- classes12.jar
- genezi
- libclntsh.so
- libclntsh.so.10.1
- libnnz10.so
- libocci.so.10.1
- libociicus.so
- libocijdbc10.so
- ojdbc14.jar
d sdk
>>> import os
>>> os.path.islink(os.path.join('parts', 'python-oracle', 'libclntsh.so'))
True
>>> os.readlink(os.path.join('parts', 'python-oracle', 'libclntsh.so'))
'.../parts/python-oracle/libclntsh.so.10.1'
In the bin directory there is a wrapper which sets the LD_LIBRARY_PATH (or DYLD_LIBRARY_PATH on darwin) and the ORACLE_HOME environment variables:
>>> ls('bin')
- buildout
- python-oracle
The wrapper can be called like any python interpreter:
>>> system(os.path.join('bin', 'python-oracle') +
... """ -c "import os; print os.environ['ORACLE_HOME']" """)
'.../parts/python-oracle\n'
>>> script = '''\ ... import os ... import sys ... if sys.platform == 'darwin': ... varname = 'DYLD_LIBRARY_PATH' ... else: ... varname = 'LD_LIBRARY_PATH' ... print os.environ[varname] ... '''
>>> system(os.path.join('bin', 'python-oracle') +
... """ -c "%s" """ % script)
'.../parts/python-oracle\n'
On Mac OS X / Darwin the libraries are not called .so but .dylib. The recipe handles this correctly:
>>> basiclite = os.path.join( ... os.path.dirname(__file__), 'basiclite-darwin.zip') >>> sdk = os.path.join( ... os.path.dirname(__file__), 'sdk-darwin.zip')
Both files have to be configured in the buildout:
>>> write("buildout.cfg", """
... [buildout]
... parts = python-oracle
... python = python-oracle
...
... [python-oracle]
... recipe = gocept.cxoracle
... instant-client = %(basiclite)s
... instant-sdk = %(sdk)s
...
... """ % {'basiclite': basiclite,
... 'sdk': sdk}
... )
>>> print system(buildout), Uninstalling python-oracle. Installing python-oracle.
The archives are merged as for linux, the a symlink is libclntsh.dylib -> libclntsh.dylib.10.1 this time:
>>> ls('parts', 'python-oracle')
- BASIC_LITE_README
- classes12.jar
- genezi
- libclntsh.dylib
- libclntsh.dylib.10.1
- libnnz10.dylib
- libocci.dylib.10.1
- libociicus.dylib
- libocijdbc10.dylib
- libocijdbc10.jnilib
- ojdbc14.jar
d sdk
>>> import os
>>> os.path.islink(os.path.join('parts', 'python-oracle', 'libclntsh.dylib'))
True
>>> os.readlink(os.path.join('parts', 'python-oracle', 'libclntsh.dylib'))
'.../parts/python-oracle/libclntsh.dylib.10.1'
When an archive cannot be extracted we’ll get an informative error:
>>> write("buildout.cfg", """
... [buildout]
... parts = python-oracle
... python = python-oracle
...
... [python-oracle]
... recipe = gocept.cxoracle
... instant-client = /does/not/exist
... instant-sdk = %(sdk)s
...
... """ % {'sdk': sdk}
... )
>>> print system(buildout),
Uninstalling python-oracle.
Installing python-oracle.
While:
Installing python-oracle.
<BLANKLINE>
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
...
Exception: Extraction of file '/does/not/exist' failed.
Changes
0.1.1 (2008-08-29)
Fixed brown bag release 0.1
0.1 (2008-08-29)
first release
Metadata
Release files for gocept.cxoracle 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gocept.cxoracle-0.1.1.tar.gz | 11.1 kB | Without provenance | Details for gocept.cxoracle-0.1.1.tar.gz |
Release files / gocept.cxoracle-0.1.1.tar.gz
| Download URL | gocept.cxoracle-0.1.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5880f9896e38c67b8847c16aba5bee2a2599119ce409e4291bfd8157e008dfb9
|
|
BLAKE2b-256 checksum How to use checksums |
aafb496a682212f64a08b1cbb5af9b1039c7d327fd4d1e2eeb6df07a1624d100
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for gocept.cxoracle 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.