In order to correctly link with static libopenvswitch.a library,
users should also provide required cflags and all the libraries
libopenvswitch.a was actually built with and depends on. Otherwise,
it's not possible to link correctly.
Fixes: 671f93fe42d3 ("python: Allow building json C extension with static OVS
library.")
Signed-off-by: Ilya Maximets <[email protected]>
---
python/setup.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/python/setup.py b/python/setup.py
index 2d94e35f3..1c9576aa9 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -65,12 +65,16 @@ class try_build_ext(build_ext):
# Allow caller of setup.py to pass in libopenvswitch.a as an object for linking
-# through the use of LDFLAGS environment variable when not building a shared
-# openvswitch library.
+# plus all the dependencies through the use of 'extra_cflags' and 'extra_libs'
+# environment variables when not building a shared openvswitch library.
+
if os.environ.get('enable_shared', '') == 'no':
- json_libraries = []
+ libraries = []
else:
- json_libraries = ['openvswitch']
+ libraries = ['openvswitch']
+
+extra_cflags = os.environ.get('extra_cflags', '').split()
+extra_libs = os.environ.get('extra_libs', '').split()
setup_args = dict(
@@ -94,8 +98,11 @@ setup_args = dict(
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
- ext_modules=[setuptools.Extension("ovs._json", sources=["ovs/_json.c"],
- libraries=json_libraries)],
+ ext_modules=[setuptools.Extension("ovs._json",
+ sources=["ovs/_json.c"],
+ libraries=libraries,
+ extra_compile_args=extra_cflags,
+ extra_link_args=extra_libs)],
cmdclass={'build_ext': try_build_ext},
install_requires=['sortedcontainers'],
extras_require={':sys_platform == "win32"': ['pywin32 >= 1.0'],
--
2.34.3
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev