Update Python build commands for Bookworm
In Bookworm's version of setuptools, direct calls to setup.py are deprecated and no longer guaranteed to work. One of the recommended commands is to use the `build` python package to build packages, and call it with `python -m build`. This, by default, builds the packages in a virtualenv to ensure that only the specified dependencies in setup.py are needed to build the package. This also extends to running tests, where directly calling `setup.py test` may not work, and the recommended alternatives are to either call `pytest` directly, or call `tox` or `nox.` More details are available at [1]. For SONiC's use case, for building python packages, we cannot build all Python packages in a virtualenv since there are dependencies that we would have built earlier, and these packages are not pushed to pypi or any package registry. (There may be a cleaner approach to this, though, but I'm not aware of it.) For this reason, the `-n` flag is added to not build the package in a virtualenv. For testing, `pytest` is now called instead of `setup.py test`. [1] https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
This commit is contained in:
parent
22a0e876cc
commit
cdc0237971
5
slave.mk
5
slave.mk
@ -925,8 +925,13 @@ $(addprefix $(PYTHON_WHEELS_PATH)/, $(SONIC_PYTHON_WHEELS)) : $(PYTHON_WHEELS_PA
|
||||
ifneq ($(CROSS_BUILD_ENVIRON),y)
|
||||
# Use pip instead of later setup.py to install dependencies into user home, but uninstall self
|
||||
pip$($*_PYTHON_VERSION) install . && pip$($*_PYTHON_VERSION) uninstall --yes `python$($*_PYTHON_VERSION) setup.py --name`
|
||||
ifeq ($(BLDENV),bookworm)
|
||||
if [ ! "$($*_TEST)" = "n" ]; then pip$($*_PYTHON_VERSION) install ".[testing]" && pip$($*_PYTHON_VERSION) uninstall --yes `python$($*_PYTHON_VERSION) setup.py --name` && python$($*_PYTHON_VERSION) -m pytest $(LOG); fi
|
||||
python$($*_PYTHON_VERSION) -m build -n $(LOG)
|
||||
else
|
||||
if [ ! "$($*_TEST)" = "n" ]; then python$($*_PYTHON_VERSION) setup.py test $(LOG); fi
|
||||
python$($*_PYTHON_VERSION) setup.py bdist_wheel $(LOG)
|
||||
endif
|
||||
else
|
||||
{
|
||||
export PATH=$(VIRTENV_BIN_CROSS_PYTHON$($*_PYTHON_VERSION)):${PATH}
|
||||
|
Loading…
Reference in New Issue
Block a user