RDConfig

Module RDConfig |
[hide private]
[frames] | no frames]

# Source Code for Module RDConfig

      1  #  $Id$
      2  #
      3  #  Copyright (C) 2000-2010 Rational Discovery LLC
      4  #
      5  #   @@ All Rights Reserved @@
      6  #  This file is part of the RDKit.
      7  #  The contents are covered by the terms of the BSD license
      8  #  which is included in the file license.txt, found at the root
      9  #  of the RDKit source tree.
     10  #
     11  """ Configuration for the RDKit Python code
     12
     13  """
     14
     15  import os, sys
     16  if 'RDBASE' in os.environ:
     17    RDBaseDir = os.environ['RDBASE']
     18    RDCodeDir = os.path.join(RDBaseDir, 'rdkit')
     19    RDDataDir = os.path.join(RDBaseDir, 'Data')
     20    RDDocsDir = os.path.join(RDBaseDir, 'Docs')
     21    RDDemoDir = os.path.join(RDBaseDir, 'Demo')
     22    RDBinDir = os.path.join(RDBaseDir, 'bin')
     23    RDProjDir = os.path.join(RDBaseDir, 'Projects')
     24    RDContribDir = os.path.join(RDBaseDir, 'Contrib')
     25  elif 'CONDA_DEFAULT_ENV' in os.environ:
     26    # we are running in a conda environ.
     27    RDCodeDir = os.path.dirname(__file__)
     28    splitdir = RDCodeDir.split(os.path.sep)
     29    condaDir = splitdir[:-4]
     30    if condaDir[0] == '':
     31      condaDir[0] = os.path.sep
     32    condaDir += ['share', 'RDKit']
     33    _share = os.path.join(*condaDir)
     34    RDDataDir = os.path.join(_share, 'Data')
     35    RDDocsDir = os.path.join(_share, 'Docs')
     36    RDProjDir = os.path.join(_share, 'Projects')
     37    RDContribDir = os.path.join(_share, 'Contrib')
     38  else:
     39    from rdkit.RDPaths import *
     40
     41  rpcTestPort = 8423
     42  pythonTestCommand = "python"
     43
     44  defaultDBUser = 'sysdba'
     45  defaultDBPassword = 'masterkey'
     46
     47
     48 -class ObsoleteCodeError(Exception):
     49    pass
     50
     51
     52 -class UnimplementedCodeError(Exception):
     53    pass
     54
     55  # ---------------------
     56  # the following block contains stuff used by the
     57  # testing infrastructure
     58  if sys.platform == 'win32':
     59    pythonExe = sys.executable
     60  else:
     61    pythonExe = "python"
     62
     63  # ---------------------
     64  # the following block contains stuff controlling database access:
     65  usePgSQL = False
     66  useSqlLite = False
     67  if not os.environ.get('RD_USESQLLITE', ''):
     68    try:
     69      from pyPgSQL import PgSQL
     70      usePgSQL = True
     71    except ImportError:
     72      usePgSQL = False
     73  if not usePgSQL:
     74    try:
     75      # python2.5 has this:
     76      import sqlite3
     77      useSqlLite = True
     78    except ImportError:
     79      try:
     80        # earlier versions of python:
     81        from pysqlite2 import dbapi2
     82        useSqlLite = True
     83      except ImportError:
     84        pass
     85
     86  if usePgSQL:
     87    RDTestDatabase = '::RDTests'
     88    RDDataDatabase = '::RDData'
     89  elif useSqlLite:
     90    RDTestDatabase = os.path.join(RDDataDir, "RDTests.sqlt")
     91    RDDataDatabase = os.path.join(RDDataDir, "RDData.sqlt")
     92  else:
     93    RDTestDatabase = None
     94    RDDataDatabase = None
     95
     96  # ---------------------
     97  # the following block contains stuff controlling the program used for
     98  #  3D molecular visualization:
     99  molViewer = os.environ.get('RD_MOLVIEWER', 'PYMOL').upper()
    100