I have some code in a setup.py file that checks for a third-party SDK that must be manually installed before the application is installed:
import sys
from setuptools import setup
# ---- BEGIN SDK CHECK
try:
import pyzed.sl
except ImportError:
print("ERROR: You must manually install the ZED Python SDK first.")
sys.exit(1)
zed_version = [int(p) for p in pyzed.sl.Camera.get_sdk_version().split(".")]
if zed_version < [4,0,8]:
print("ERROR: ZED SDK 4.0.8 or higher is required, you must update the ZED SDK first.")
sys.exit(1)
# ---- END SDK CHECK
setup(...)
However, I only want this code to execute when the package is installed, not when the package source tarball / wheel is built. That is:
- I want it to execute when
pip install ...is run. - I do not want it to execute when
python -m build -x ...is run.
Is there some way to accomplish this? E.g. is there a way to determine if setup.py was invoked via pip install but not via python -m build? Or is there some other way to only run checks on install?
Ensure that you have the python dev libraries installed that are necessary to build packages.
On debian eco system based distros like ubuntu and so on you will need to install seperatly, called "python-dev": https://packages.ubuntu.com/search?keywords=python-dev
and on RPM based systems it's called "python-devel"
https://rpmfind.net/linux/rpm2html/search.php?query=python-devel
hope it helps.