78 """Run SWIG for this OS and make the wrapper limited-API clean (as `make swig3` does)."""
79 os.makedirs(GEN, exist_ok=
True)
80 wrap = os.path.join(GEN,
"cmsdk3_wrap.cxx")
81 py = os.path.join(GEN,
"cmsdk3.py")
82 iface = os.path.join(ROOT,
"cmsdk.i")
83 if os.path.isfile(wrap)
and os.path.isfile(py)
and os.path.getmtime(wrap) >= os.path.getmtime(iface):
87 if IS_LINUX
and sys.maxsize > 2**32:
88 cmd.append(
"-DSWIGWORDSIZE64")
89 cmd += [
"-module",
"cmsdk3",
"-I" + os.path.join(ROOT,
"include"),
"-outdir", GEN,
"-o", wrap, iface]
90 print(
"cmsdk3 wheel: " +
" ".join(cmd), flush=
True)
91 subprocess.check_call(cmd)
92 subprocess.check_call([sys.executable, os.path.join(ROOT,
"tools",
"swig_limited_api.py"), wrap])
98 if os.environ.get(
"CMSDK_OPENSSL_INCLUDE")
or os.environ.get(
"CMSDK_OPENSSL_LIB"):
99 return ([os.environ[
"CMSDK_OPENSSL_INCLUDE"]]
if os.environ.get(
"CMSDK_OPENSSL_INCLUDE")
else [],
100 [os.environ[
"CMSDK_OPENSSL_LIB"]]
if os.environ.get(
"CMSDK_OPENSSL_LIB")
else [])
101 pref = os.environ.get(
"CMSDK_OPENSSL_DIR")
102 if not pref
and IS_MAC:
103 for f
in (
"openssl@3",
"openssl"):
105 pref = subprocess.check_output([
"brew",
"--prefix", f], text=
True, stderr=subprocess.DEVNULL).strip()
110 inc.append(os.path.join(pref,
"include"))
111 lib.append(os.path.join(pref,
"lib64" if os.path.isdir(os.path.join(pref,
"lib64"))
else "lib"))
126 files = CPPFILES + ([
"direntwin.cpp"]
if IS_WIN
else [])
127 sources = [os.path.relpath(p, HERE)
for p
in [wrap] + [os.path.join(SRC,
"src", f)
for f
in files]]
128 macros = [(
"Py_LIMITED_API", PY_LIMITED_API), (
"SWIG_PYTHON_INTERPRETER_NO_DEBUG",
None), (
"PSYPRO",
None)]
129 include_dirs = [os.path.relpath(os.path.join(SRC,
"include"), HERE)]
130 library_dirs, libraries, cflags, ldflags = [], [], [], []
132 macros += [(
"WIN32",
None), (
"NDEBUG",
None), (
"_WINDOWS",
None), (
"_WINDLL",
None), (
"PSYNCL",
None)]
133 libraries += [
"Ws2_32",
"Psapi",
"Rpcrt4",
"IPHlpApi",
"Advapi32",
"User32",
"Crypt32"]
134 cflags += [
"/EHsc",
"/O2",
"/bigobj"]
136 macros += [(
"Darwin" if IS_MAC
else "Linux",
None), (
"_GNU_SOURCE",
None), (
"_REENTRANT",
None),
137 (
"_THREAD_SAFE",
None)]
138 cflags += [
"-O2",
"-std=c++11",
"-Wno-parentheses",
"-Wno-unused-variable",
"-Wno-sign-compare"]
141 ldflags += [
"-Wl,-s"]
143 cflags += [
"-Wno-invalid-source-encoding"]
145 macros.append((
"_USE_SSL_",
None))
149 libraries += [
"libssl",
"libcrypto"]
if IS_WIN
else [
"ssl",
"crypto"]
150 if IS_LINUX
and any(os.path.isfile(os.path.join(d,
"libssl.a"))
and
151 not os.path.exists(os.path.join(d,
"libssl.so"))
for d
in lib):
154 ldflags += [
"-Wl,--exclude-libs,ALL"]
156 libraries += [
"pthread",
"dl",
"rt"]
158 "_cmsdk3", sources=sources, include_dirs=include_dirs, define_macros=macros,
159 library_dirs=library_dirs, libraries=libraries, extra_compile_args=cflags, extra_link_args=ldflags,
160 language=
"c++", py_limited_api=
True,