File: setup.py

package info (click to toggle)
python-cx-oracle 8.3.0-3
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, sid
  • size: 3,276 kB
  • sloc: ansic: 10,406; python: 9,358; sql: 1,724; makefile: 31
file content (87 lines) | stat: -rw-r--r-- 2,869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"""
Setup script for cx_Oracle.
"""

import os
import pkg_resources
import setuptools
import sys
import time

# check minimum supported Python version
if sys.version_info[:2] < (3, 6):
    raise Exception("Python 3.6 or higher is required. " +
            "For python 2, use 'pip install cx_Oracle==7.3'")

# check minimum supported version of setuptools
pkg_resources.require("setuptools>=40.6.0")

# define build constants
BUILD_VERSION = "8.3.0"

# setup extra link and compile args
extra_link_args = []
extra_compile_args = []
if sys.platform == "aix4":
    extra_compile_args.append("-qcpluscmt")
elif sys.platform == "aix5":
    extra_compile_args.append("-DAIX5")
elif sys.platform == "cygwin":
    extra_link_args.append("-Wl,--enable-runtime-pseudo-reloc")
elif sys.platform == "darwin":
    extra_link_args.append("-shared-libgcc")

# define cx_Oracle sources
source_dir = "src"
sources = [os.path.join(source_dir, n) \
           for n in sorted(os.listdir(source_dir)) if n.endswith(".c")]
depends = ["src/cxoModule.h"]

# define ODPI-C sources, libraries and include directories; if the environment
# variables ODPIC_INC_DIR and ODPIC_LIB_DIR are both set, assume these
# locations contain a compiled installation of ODPI-C; otherwise, use the
# source of ODPI-C found in the odpi subdirectory
dpi_include_dir = os.environ.get("ODPIC_INC_DIR")
dpi_lib_dir = os.environ.get("ODPIC_LIB_DIR")
if dpi_include_dir and dpi_lib_dir:
    dpi_sources = []
    include_dirs = [dpi_include_dir]
    libraries = ["odpic"]
    library_dirs = [dpi_lib_dir]
else:
    include_dirs = ["odpi/include", "odpi/src"]
    dpi_source_dir = os.path.join("odpi", "src")
    dpi_sources = [os.path.join(dpi_source_dir, n) \
            for n in sorted(os.listdir(dpi_source_dir)) if n.endswith(".c")]
    depends.extend(["odpi/include/dpi.h", "odpi/src/dpiImpl.h",
            "odpi/src/dpiErrorMessages.h"])
    libraries = []
    library_dirs = []

# Define the build time, either from SOURCE_DATE_EPOCH or the machine clock.
# See <https://reproducible-builds.org/docs/source-date-epoch/> for details.
build_time = time.strftime(
        "%Y-%m-%d %H:%M:%S %Z",
        time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
)

# setup the extension
extension = setuptools.Extension(
        name="cx_Oracle",
        include_dirs=include_dirs,
        extra_compile_args=extra_compile_args,
        define_macros=[
            ("CXO_BUILD_VERSION", BUILD_VERSION),
            ("CXO_BUILD_TIME", build_time),
        ],
        extra_link_args=extra_link_args,
        sources=sources + dpi_sources,
        depends=depends,
        libraries=libraries,
        library_dirs=library_dirs)

# perform the setup
setuptools.setup(
        version=BUILD_VERSION,
        data_files=[ ("cx_Oracle-doc", ["LICENSE.txt", "README.txt"]) ],
        ext_modules=[extension])