@@ -70,22 +70,41 @@ def run(self):
70
70
sourceDir = "src"
71
71
sources = [os .path .join (sourceDir , n ) \
72
72
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 = []
78
96
79
97
# setup the extension
80
98
extension = Extension (
81
99
name = "cx_Oracle" ,
82
- include_dirs = [ "odpi/include" , "odpi/src" ] ,
100
+ include_dirs = includeDirs ,
83
101
extra_compile_args = extraCompileArgs ,
84
102
define_macros = [("CXO_BUILD_VERSION" , BUILD_VERSION )],
85
103
extra_link_args = extraLinkArgs ,
86
104
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 )
89
108
90
109
# perform the setup
91
110
setup (
0 commit comments