diff options
author | Ilya Maximets <i.maximets@ovn.org> | 2022-07-25 14:19:38 +0200 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-07-29 17:08:28 +0200 |
commit | 791c47273983b830dbc840ae7bf18a23bc9e72e4 (patch) | |
tree | 1fc6b34a0eb6351d9d76128fdba2a612d18e4667 /python | |
parent | 66824fb8da52b7942122f9dda4cd09aea593c17f (diff) | |
download | openvswitch-791c47273983b830dbc840ae7bf18a23bc9e72e4.tar.gz |
python: Add ability to pass extra libs and cflags for C extension.
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.")
Acked-by: Frode Nordahl <frode.nordahl@canonical.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/setup.py | 19 |
1 files 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'], |