Skip to content

Commit

Permalink
python: Allow building json C extension with static OVS library.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
fnordahl authored and igsilya committed Jul 15, 2022
1 parent ae262dd commit 671f93f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,6 +64,15 @@ def build_extension(self, 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',
Expand All @@ -85,7 +95,7 @@ def build_extension(self, ext):
'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']},
Expand Down

0 comments on commit 671f93f

Please sign in to comment.