summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorFrode Nordahl <frode.nordahl@canonical.com>2022-07-14 17:55:42 +0200
committerIlya Maximets <i.maximets@ovn.org>2022-07-15 13:45:55 +0200
commit671f93fe42d3c15aa0bf883bef0f05716bc2b18b (patch)
tree90efbf5725e1396430c61adecf14038bb95c2c06 /python
parentae262ddf229a05e8f400332cb6fbd31980f450f9 (diff)
downloadopenvswitch-671f93fe42d3c15aa0bf883bef0f05716bc2b18b.tar.gz
python: Allow building json C extension with static OVS library.
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. To accomplish this set the `enable_shared` environment variable to 'no'. Example: LDFLAGS=lib/libopenvswitch.a enable_shared=no setup.py install Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'python')
-rw-r--r--python/setup.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/python/setup.py b/python/setup.py
index cfe01763f..3d4c360ef 100644
--- a/python/setup.py
+++ b/python/setup.py
@@ -10,6 +10,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import sys
from distutils.command.build_ext import build_ext
@@ -63,6 +64,15 @@ class try_build_ext(build_ext):
raise BuildFailed()
+# 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.
+if os.environ.get('enable_shared', '') == 'no':
+ json_libraries = []
+else:
+ json_libraries = ['openvswitch']
+
+
setup_args = dict(
name='ovs',
description='Open vSwitch library',
@@ -85,7 +95,7 @@ setup_args = dict(
'Programming Language :: Python :: 3.5',
],
ext_modules=[setuptools.Extension("ovs._json", sources=["ovs/_json.c"],
- libraries=['openvswitch'])],
+ libraries=json_libraries)],
cmdclass={'build_ext': try_build_ext},
install_requires=['sortedcontainers'],
extras_require={':sys_platform == "win32"': ['pywin32 >= 1.0']},