-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Description
Description
Running python setup.py install
for the Python package raises the following deprecation warning:
/Users/jlamb/mambaforge/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).
Here are some of the main things we need to know:
...as of the last few years all direct invocations of setup.py are effectively deprecated in favor of invocations via purpose-built and/or standards-based CLI tools like pip, build and tox.
As mentioned in this issue, direct setup.py invocations have effectively been unmaintained for several years now. Whenever someone raises an issue with a reproducer that involves invoking setup.py, the maintainers ask for a reproducer that doesn't hit this code path, and if one can't be found the issue is closed. Put another way, direct invocations of setup.py that currently work for you do so essentially by chance — if something breaks, you are on your own.
Reproducible example
I observed this warning building from source on macOS 12.2.1, with Python v3.9.7 and setuptools==59.8.0
.
git clone --recursive https://github.com/microsoft/LightGBM.git
cd LightGBM/python-package
This warning is raised with python setup.py install
.
python setup.py install
It is also raised with pip
.
pip install -v .
You can also see this warning on LightGBM's CI builds that use python setup.py {command}
. For example, the most recent Linux regular
job running on Azure DevOps (build link).
References
This warning was added in setuptools=v58.3.0
(October 22, 2021), pypa/setuptools#2824.
That PR mentions https://www.python.org/dev/peps/pep-0517/ as a description of the standard packages should meet to continue to be compliant with the main Python package management tools.
The warning comes from setuptools.command.install.initialize_options()
: https://github.com/pypa/setuptools/blob/391bb5d4d09c9eb8d6b2b98968e623455ae0a384/setuptools/command/install.py#L32-L38.
lightgbm
currently sub-classes setuptools.command.install
to customize the behavior of setup.py install
.
LightGBM/python-package/setup.py
Lines 220 to 225 in f6d654b
class CustomInstall(install): | |
user_options = install.user_options + LIGHTGBM_OPTIONS | |
def initialize_options(self) -> None: | |
install.initialize_options(self) |
It also does that to customize setup.py {install_lib, bdist_wheel, sdist}
.
LightGBM/python-package/setup.py
Lines 361 to 366 in f6d654b
cmdclass={ | |
'install': CustomInstall, | |
'install_lib': CustomInstallLib, | |
'bdist_wheel': CustomBdistWheel, | |
'sdist': CustomSdist, | |
}, |
- "pyproject.toml quickstart" (setuptools docs)
- "Configuring setuptools using setup.cfg files" (setuptools docs)
Why does this matter?
If nothing is changed, the LightGBM Python package might eventually not be installable with some future versions of Python / setuptools
.
What should be done?
I don't have a recommendation yet.
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html, https://www.python.org/dev/peps/pep-0517/, and the other things they link to are very detailed and I'm not deeply familiar with the details of how setuptools
works.
Just opening this up to track discussion about this issue.