Skip to content

Commit

Permalink
Pypi:Add nmstate C library check on pip install
Browse files Browse the repository at this point in the history
Added check for the nmstate C library . If the library is not found,error occurs, guiding the user to install the nmstate C library separately before installing the Python package. This enhancement ensures the pypi package is efficiantly usabel on install.

Signed-off-by: jona42-ui <jonathanthembo123@gmail.com>
  • Loading branch information
jona42-ui committed May 3, 2024
1 parent d03a52f commit 50c5ab2
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions rust/src/python/setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

import ctypes
import sys
import setuptools


def requirements():
req = []
with open("requirements.txt") as fd:
with open("requirements.txt", encoding="utf-8") as fd:
for line in fd:
line.strip()
if not line.startswith("#"):
req.append(line)
return req


def check_nmstate_c_library():
if "bdist_rpm" not in sys.argv:
try:
ctypes.cdll.LoadLibrary("libnmstate.so.2")
except OSError as exc:
raise RuntimeError(
"Error: nmstate C library not found. "
"Please install nmstate C library separately "
"before installing the Python package."
"See: https://nmstate.io/user/install.html"
) from exc


check_nmstate_c_library()


setuptools.setup(
name="nmstate",
version="2.2.31",
Expand Down

0 comments on commit 50c5ab2

Please sign in to comment.