Re: [cx-oracle-users] Wheels again
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2017-04-19 02:37:21
|
All, The newly released 6.0 beta 1 is the first release that makes use of wheels -- mostly thanks to ODPI-C which has the ability to build once and use with any Oracle client libraries (so long as they are 11.2, 12.1 or 12.1, that is!). So at long last you can do a pip install and get the right binary for your platform (so long as it is Windows or Linux anyway!). Anthony On Tue, Apr 26, 2016 at 9:53 AM, Anthony Tuininga < ant...@gm...> wrote: > Thanks for these suggestions. It will take some time to consider which > approach to take. I'll reply back again when I have a positive decision > made. > > One concern that eliminates a few of these possibilities is portability. > cx_Oracle runs on more than just Windows so Windows-specific code/concepts > can't be used. Creating differently named modules (for client version) or > creating a wrapper module that imports the right sub-module at run-time are > the two top choices I am considering right now. If anyone else has any > thoughts on which approach would be best to take, I'd love to hear from you. > > Anthony > > On Thu, Apr 21, 2016 at 7:24 PM, Kubo Takehiro <ku...@ji...> wrote: > >> Hi, >> >> I know a little about python and nothing about wheels. >> However I have three ideas. >> >> 1. Distribute cx_Oracle compiled for Oracle 10g. >> >> Oracle client library ABI keeps backward compatibility on Windows. >> When a binary file is compiled for Oracle 10g, it works with Oracle >> 10g, 11g and 12c. >> However it cannot use features depends on Oracle 11g and 12c clients. >> >> 2. Check Oracle client version at runtime. >> >> This is ideal for pre-compiled packages but not practical because this >> needs >> too many changes in cx_Oracle. >> >> Add the following code to Module_Initialize() in cx_Oracle.c >> >> HMODULE hMod = GetModuleHandle("OCI.DLL"); >> void (*func)(sword*, sword*, sword*, sword*, sword*) = (void >> (*)(sword*, sword*, sword*, sword*, sword*))GetProcAddress(hMod, >> "OCIClientVersion"); >> if (func == NULL) { >> oracle_version_hex = ORACLE_VERSION(10, 1) >> } else { >> sword major, minor, update, patch, port; >> (*func)(&major, &minor, &update, &patch, &port); >> oracle_version_hex = ORACLE_VERSION(major, minor); >> } >> >> and rewrite code such as >> #if ORACLE_VERSION_HEX >= ORACLE_VERSION(11,1) >> ... >> #endif >> to >> if (oracle_client_hex >= ORACLE_VERSION(11,1)) { >> ... >> } >> >> Use function pointers retrieved by GetProcAddress() for functions >> added in Oracle 11g and 12c, >> >> 3. Add a bootstrap module if wheels can include more than one module. >> >> Compile cx_Oracle for Oracle 10.1, 10.2, 11.1, 11.2 and 12.1 and rename >> them >> to cx_Oracle.10.1.dll, cx_Oracle.10.2.dll, cx_Oracle.11.1.dll, >> cx_Oracle.11.2.dll and cx_Oracle.12.1.dll respectively. >> >> Compile the following code as cx_Oracle.dll. >> >> // This is incomplete code. no error checks. >> >> typedef int sword; >> >> static void *get_init_func(const char *init_func_name) >> { >> HMODULE hMod; >> void (*func)(sword*, sword*, sword*, sword*, sword*); >> char dll_name[30]; >> char dll_full_path[MAX_PATH]; >> >> // Get the Oracle client version and fill dll_name. >> hMod = LoadLibrary("OCI.DLL"); >> func = (void (*)(sword*, sword*, sword*, sword*, >> sword*))GetProcAddress(hMod, "OCIClientVersion"); >> if (func == NULL) { >> strcpy(dll_name, "cx_Oracle.10.1.dll"); >> } else { >> sword major, minor, update, patch, port; >> (*func)(&major, &minor, &update, &patch, &port); >> sprintf(dll_name, "cx_Oracle.%d.%d.dll", major, minor); >> } >> FreeLibrary(hMod); >> >> // get the current module handle. >> GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, >> &get_init_func, &hMod); >> ... fill dll_full_path with the directory name containing the >> current module by using GetModuleFileName(hMod, ...). >> ... append dll_name to dll_full_path. >> >> // Load the real cx_Oracle module and get the module initializer >> function. >> hMod = LoadLibrary(dll_full_path); >> return GetProcAddress(hMod, init_func_name); >> } >> >> #if PY_MAJOR_VERSION >= 3 >> PyMODINIT_FUNC PyInit_cx_Oracle(void) >> { >> PyObject *(*init)(void) = >> (PyObject*(*)(void))get_init_func("PyInit_cx_Oracle"); >> return (*init)(); >> } >> #else >> void initcx_Oracle(void) >> { >> void (*init)(void) = (void(*)(void))get_init_func("initcx_Oracle"); >> (*init)(); >> } >> #endif >> >> >> Put cx_Oracle.dll, cx_Oracle.10.1.dll, cx_Oracle.10.2.dll, >> cx_Oracle.11.1.dll, cx_Oracle.11.2.dll >> and cx_Oracle.12.1.dll in a directory. >> >> ------------------------------------------------------------ >> ------------------ >> Find and fix application performance issues faster with Applications >> Manager >> Applications Manager provides deep performance insights into multiple >> tiers of >> your business applications. It resolves application problems quickly and >> reduces your MTTR. Get your free trial! >> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z >> _______________________________________________ >> cx-oracle-users mailing list >> cx-...@li... >> https://lists.sourceforge.net/lists/listinfo/cx-oracle-users >> > > |