Skip to content

Instantly share code, notes, and snippets.

@davidjb
Last active August 13, 2017 09:23
Show Gist options
  • Save davidjb/2656902 to your computer and use it in GitHub Desktop.
Save davidjb/2656902 to your computer and use it in GitHub Desktop.
Buildout for Python database connectors (cx_Oracle, MySQL-python) and dependencies
[extra-parts]
parts +=
python-mysql
[python-mysql]
recipe = zc.recipe.egg
egg = MySQL-python
[instance1]
eggs +=
${python-mysql:egg}
#Notes about Oracle python Connectors
#------------------------------------
#Need to install libaio-dev (Debian/Ubuntu), or libaio-devel (RHEL/CentOS)
#Customise extra-parts in your buildout if you need the 32-bit versions.
#Easiest way to do this is probably to comment this out and include your
#own in your buildout.cfg.
#
#If you're working with Zope 2 or 3 with SQLAlchemy, then use `z3c.sqlalchemy`
#as a middle-level wrapper for working with SQLAlchemy. See PyPI for details.
#For integration within the ZMI (eg Z SQL Methods) see `Products.SQLAlchemyDA`.
[extra-db-parts]
parts =
python-oracle
python-oracle-instantclient-sdk
python-oracle-setup
python-oracle-cxoracle
[extra-parts]
parts +=
${extra-db-parts:parts}
[scripty]
recipe = mr.scripty
PYTHON_ORACLE_URL_64 = https://www.hpc.jcu.edu.au/plone/oracle/instantclient-basiclite-linux-x86-64-11.2.0.2.0.zip
PYTHON_ORACLE_URL_32 = https://www.hpc.jcu.edu.au/plone/oracle/instantclient-basiclite-linux32-11.2.0.1.zip
python_oracle_url =
... import platform
... is_64bit = any(['64' in x for x in platform.architecture()])
... print 'Basiclite %r' % is_64bit
... return is_64bit and self.PYTHON_ORACLE_URL_64 or self.PYTHON_ORACLE_URL_32
PYTHON_ORACLE_INSTANTCLIENT_SDK_URL_64 = https://www.hpc.jcu.edu.au/plone/oracle/instantclient-sdk-linux-x86-64-11.2.0.2.0.zip
PYTHON_ORACLE_INSTANTCLIENT_SDK_URL_32 = https://www.hpc.jcu.edu.au/plone/oracle/instantclient-sdk-linux32-11.2.0.1.zip
python_oracle_instantclient_sdk_url =
... import platform
... is_64bit = any(['64' in x for x in platform.architecture()])
... print 'Instantclient %r' % is_64bit
... return is_64bit and self.PYTHON_ORACLE_INSTANTCLIENT_SDK_URL_64 or self.PYTHON_ORACLE_INSTANTCLIENT_SDK_URL_32
[python-oracle-env]
destination = ${buildout:parts-directory}/python-oracle
ORACLE_HOME = ${:destination}
[python-oracle]
recipe = hexagonit.recipe.download
url = ${scripty:python_oracle_url}
destination = ${python-oracle-env:destination}
strip-top-level-dir = true
ignore-existing = true
[python-oracle-instantclient-sdk]
recipe = hexagonit.recipe.download
url = ${scripty:python_oracle_instantclient_sdk_url}
destination = ${python-oracle-env:destination}
strip-top-level-dir = true
ignore-existing = true
[python-oracle-setup]
recipe = plone.recipe.command
library-path = ${python-oracle-env:destination}/libclntsh.so
command = ln -s ${:library-path}* ${:library-path}
update-command = ${:command}
[python-oracle-cxoracle]
recipe = zc.recipe.egg:custom
egg = cx_Oracle
environment = python-oracle-env
#Plone configuration
#-------------------
#Note that you may need to copy and reproduce the following environment vars
#and possibly eggs.
[oracle-environment-vars]
vars =
DYLD_LIBRARY_PATH ${python-oracle-env:destination}:/opt/local/lib:/usr/lib64
LD_LIBRARY_PATH ${python-oracle-env:destination}:/usr/local/lib:/home/buildout/instance-python/python2.6/parts/opt/lib/
TNS_ADMIN ${python-oracle-env:destination}
NLS_LANG _.AL32UTF8
[instance1]
environment-vars += ${oracle-environment-vars:vars}
eggs +=
${python-oracle-cxoracle:egg}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment