Hello. Quick question here related to recent pip --install-options [deprecation] pypa/pip/issues/11358. We have a design decently described here and here.
Shortly, we have a design of our setup.py like so
user_options = [
('foo=', None, 'Specify the foo to bar.'),
and we pass parameters in command line like this
pip install . --install-option="--foo"
Now, with latest pip onboard, we get scary warning --install-option is deprecated because it forces pip to use the 'setup.py install' command which is itself deprecated.
So, what should we do now? Completely rid of class InstallCommand(install): class? In two stackoverflow questions linked above it is most common solution for passing parameters to setup.py. There are also suggestions to use environment variables or regular sys.argv parsing but both looks like workarounds.
You should use --config-settings in pip. You will need to check with the setuptools project on how you can access config settings from within your setup.py - pip simply passes a dictionary of key:value pairs to the backend and leaves it to the backend to determine how to use them.
If I am not wrong, that is a possibility for other commands (e.g. sdist, bdist_wheel, etc …) but not for the install command.
I think effectively extending install is deprecated because the logic to install packages now belongs to pip (and python setup.py install should not be used).
Unless, of course, you are using some shenanigans to customize how bdist_whell organize the file structure of the final zip archive. In that case, this is not supported yet by how setuptools handles --config-settings and the workaround would be something similar to what Miro described.
Sorry, you’re right, I missed that this was for install. This will no longer be possible in future (at least, not using pip). All installs will be done by building a wheel (or using a pre-built wheel) and installing that. There’s no option in pip to customise the install process (how to install a wheel is defined by the wheel specification, and we follow that spec).
If you want to do custom actions as part of installing a package, you’ll need a different installer, I’m afraid. (Which probably means writing your own, although that could wrap pip if you wanted, to handle the actual wheel install).
Edit: Note that setuptools have deprecated the setup.py install command, so pip really has no choice other than to drop our usage of it, even if we wanted to do otherwise (we don’t, though - we’re removing all code that special-cases setuptools in favour of using the standard build backend interface).