@@ -70,22 +70,41 @@ def run(self):
7070sourceDir = "src"
7171sources = [os .path .join (sourceDir , n ) \
7272 for n in sorted (os .listdir (sourceDir )) if n .endswith (".c" )]
73-
74- # define ODPI-C sources
75- dpiSourceDir = os .path .join ("odpi" , "src" )
76- dpiSources = [os .path .join (dpiSourceDir , n ) \
77- for n in sorted (os .listdir (dpiSourceDir )) if n .endswith (".c" )]
73+ depends = ["src/cxoModule.h" ]
74+
75+
76+ # define ODPI-C sources, libraries and include directories; if the environment
77+ # variables ODPIC_INC_DIR and ODPIC_LIB_DIR are both set, assume these
78+ # locations contain a compiled installation of ODPI-C; otherwise, use the
79+ # source of ODPI-C found in the odpi subdirectory
80+ dpiIncludeDir = os .environ .get ("ODPIC_INC_DIR" )
81+ dpiLibDir = os .environ .get ("ODPIC_LIB_DIR" )
82+ if dpiIncludeDir and dpiLibDir :
83+ dpiSources = []
84+ includeDirs = [dpiIncludeDir ]
85+ libraries = ["odpic" ]
86+ libraryDirs = [dpiLibDir ]
87+ else :
88+ includeDirs = ["odpi/include" , "odpi/src" ]
89+ dpiSourceDir = os .path .join ("odpi" , "src" )
90+ dpiSources = [os .path .join (dpiSourceDir , n ) \
91+ for n in sorted (os .listdir (dpiSourceDir )) if n .endswith (".c" )]
92+ depends .extend (["odpi/include/dpi.h" , "odpi/src/dpiImpl.h" ,
93+ "odpi/src/dpiErrorMessages.h" ])
94+ libraries = []
95+ libraryDirs = []
7896
7997# setup the extension
8098extension = Extension (
8199 name = "cx_Oracle" ,
82- include_dirs = [ "odpi/include" , "odpi/src" ] ,
100+ include_dirs = includeDirs ,
83101 extra_compile_args = extraCompileArgs ,
84102 define_macros = [("CXO_BUILD_VERSION" , BUILD_VERSION )],
85103 extra_link_args = extraLinkArgs ,
86104 sources = sources + dpiSources ,
87- depends = ["src/cxoModule.h" , "odpi/include/dpi.h" ,
88- "odpi/src/dpiImpl.h" , "odpi/src/dpiErrorMessages.h" ])
105+ depends = depends ,
106+ libraries = libraries ,
107+ library_dirs = libraryDirs )
89108
90109# perform the setup
91110setup (
0 commit comments