Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate pip install --editable calling setup.py develop #11457

Open
sbidoul opened this issue Sep 17, 2022 · 24 comments
Open

Deprecate pip install --editable calling setup.py develop #11457

sbidoul opened this issue Sep 17, 2022 · 24 comments
Labels
C: editable Editable installations type: deprecation Related to deprecation / removal.
Milestone

Comments

@sbidoul
Copy link
Member

sbidoul commented Sep 17, 2022

There is now a standardized mechanism for an installer like pip to request an editable install of a project.

pip is transitioning to using this standard only instead of invoking the deprecated setup.py develop command.

What's being deprecated?

TL;DR: the execution of setup.py develop when pip does an editable install. The -e / --editable pip install option is not deprecated.

There is a standardized mechanism (called PEP 660) for an installers to request an editable install of a project. The benefit of this modern mechanism is that it allows projects packaged using other tools (formally called "build backends") such as Hatch and Poetry to support editable installs.

Since pip 21.3, pip has switched to using this mechanism where possible. Now the pip project seeks to deprecate and eventually remove the old and setuptools-specific fallback to running setup.py develop when a pyproject.toml is not present or the PEP 660 mechanism is unsupported for some reason.

Some historical context if you're interested
  • Historically, there was no standard way for installers like pip to request an editable install of a project. Thus, the -e / --editable option was implemented as a wrapper over the setup.py develop command. Using this method, only setuptools projects could use editable installs. PEP 660 defines an interface which build backends can implement in order to support editable installs.

  • If you are still interested and want more details, they are available on @ichard26's blog post on the changes in pip 24.2. You should read this issue first though!

How will this affect my project?

TL;DR: if your project does not support or function properly using the modern mechanism for editable installs, pip install -e is liable to stop working starting with pip 25.0 (Q1 2025).

If you have received a deprecation warning about a legacy editable install, pip is using the legacy setup.py develop method for performing an editable installation of your project. In practice, this usually means one of two things:

  • The pyproject.toml file doesn’t exist at all, thus pip will opt-out of the modern mechanism and use setup.py develop
  • The declared setuptools version (in the [build-system].requires field) is too old and doesn’t support PEP 660, i.e. anything older than setuptools 64.0.0

The current plan is that support for legacy editable installs will be entirely removed in pip 25.0 (Q1 2025). If your package doesn't not support or function correctly under an editable install using the modern mechanism, pip install -e will break starting with pip 25.0.

What should I do?

There are a couple of choices:

  • Add a pyproject.toml to your project, making sure the [build-system] section requires setuptools >= 64, as well as other libraries required to build your project (the equivalent of setuptools' setup_requires parameter). A basic example is included below:

    [build-system]
    # XXX: If your project needs other packages to build properly, add them to this list.
    requires = ["setuptools >= 64"]
    build-backend = "setuptools.build_meta"
  • Alternatively, enable the --use-pep517 pip option, possibly with --no-build-isolation. The --use-pip517 flag will force pip to use the modern mechanism for editable installs. --no-build-isolation may be needed if your project has build-time requirements beyond setuptools and wheel. By passing this flag, you are responsible for making sure your environment already has the required dependencies to build your package. Once the legacy mechanism is removed, --use-pep517 will have no effect and will essentially be enabled by default in this context.

Tip

If the resulting installation does not behave correctly, you may want to try the --config-setting editable_mode=compat pip option. Please consult the setuptools documentation for more information.

Tip

Which solution you choose to use depends on the project, but option one is recommended as there are other benefits to adding a pyproject.toml file. For example, you can declare your project metadata in pyproject.toml. If your project already works fine using the modern mechanism, option two is an acceptable way to silence the deprecation warning in the meanwhile.

@sbidoul sbidoul added C: editable Editable installations type: deprecation Related to deprecation / removal. labels Sep 17, 2022
@pradyunsg
Copy link
Member

pradyunsg commented Oct 7, 2022

This is complicated by the fact that numpy and everything that uses numpy.distutils as a build-dependency cannot be built with setuptools >= 60. setuptools v64.0.0 was the first version to add a PEP 660 implementation.

https://numpy.org/doc/stable/reference/distutils_status_migration.html
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

@pradyunsg
Copy link
Member

Adding a cross-reference to the idea of dropping support for this, starting Python 3.12+ (circa #8102 (comment)).

This also makes sense since we'd stop install setuptools by default in ensurepip starting with that Python version, and get-pip.py as well, I imagine.

@edmorley
Copy link
Contributor

Is it worth adding a deprecation message for the setup.py develop fallback in the next Pip release?

@edmorley
Copy link
Contributor

Is here the correct place for the deprecation warning?

if self.editable and not self.is_wheel:
install_editable_legacy(
global_options=global_options if global_options is not None else [],
prefix=prefix,
home=home,
use_user_site=use_user_site,
name=self.req.name,
setup_py_path=self.setup_py_path,
isolated=self.isolated,
build_env=self.build_env,
unpacked_source_directory=self.unpacked_source_directory,
)
self.install_succeeded = True
return

@uranusjr
Copy link
Member

I think so, either this or inside install_editable_legacy

@sbidoul
Copy link
Member Author

sbidoul commented Jul 4, 2024

Is it worth adding a deprecation message for the setup.py develop fallback in the next Pip release?

@edmorley I personally think so yes.

A question I have is if the deprecation message should mention that --config-setting editable_mode=compat exists for maximum compatibility.

edmorley added a commit to edmorley/pip that referenced this issue Jul 7, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 7, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
@edmorley
Copy link
Contributor

edmorley commented Jul 7, 2024

I've opened #12830 to add the deprecation warning for the setup.py develop fallback.

edmorley added a commit to edmorley/pip that referenced this issue Jul 7, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 13, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 13, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 13, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 13, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
edmorley added a commit to edmorley/pip that referenced this issue Jul 14, 2024
Deprecates `pip install --editable` falling back to `setup.py develop`
when using a setuptools version that does not support PEP 660
(setuptools v63 and older).

See:
https://peps.python.org/pep-0660/
https://setuptools.pypa.io/en/latest/history.html#v64-0-0

Closes pypa#11457.
@sbidoul sbidoul reopened this Jul 15, 2024
@sbidoul sbidoul added this to the 25.0 milestone Jul 15, 2024
@sneakers-the-rat
Copy link

Nice work yall ♥

github-actions bot pushed a commit to ARM-software/lisa that referenced this issue Sep 12, 2024
FIX

Fix the pip warning explained here:
pypa/pip#11457

By following this procedure:
pypa/pip#11457 (comment)
apb-arredoer added a commit to portdebarcelona/PLANOL-generic_python_packages that referenced this issue Sep 23, 2024
apb-arredoer added a commit to portdebarcelona/PLANOL-generic_python_packages that referenced this issue Sep 23, 2024
chuckwondo added a commit to NASA-IMPACT/hls-orchestration that referenced this issue Oct 9, 2024
- Have tox install current LTS release of nodejs
- Have tox install latest v2.x release of CDK CLI
- Update pip editable install to work with pip 25+

The last point addresses the following warning when running tox:

> DEPRECATION: Legacy editable install of hls_lambda_layer==0.0.0 from
> file:///Users/chuck/src/NASA-IMPACT/hls-orchestration/layers/hls_lambda_layer/python
> (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour
> change. A possible replacement is to add a pyproject.toml or enable
> --use-pep517, and use setuptools >= 64. If the resulting installation
> is not behaving as expected, try using --config-settings editable_mode=compat.
> Please consult the setuptools documentation for more information.
> Discussion can be found at pypa/pip#11457
chuckwondo added a commit to NASA-IMPACT/hls-orchestration that referenced this issue Oct 9, 2024
- Have tox install current LTS release of nodejs
- Have tox install latest v2.x release of CDK CLI
- Update pip editable install to work with pip 25+

The last point addresses the following warning when running tox:

> DEPRECATION: Legacy editable install of hls_lambda_layer==0.0.0 from
> file:///Users/chuck/src/NASA-IMPACT/hls-orchestration/layers/hls_lambda_layer/python
> (setup.py develop) is deprecated. pip 25.0 will enforce this behaviour
> change. A possible replacement is to add a pyproject.toml or enable
> --use-pep517, and use setuptools >= 64. If the resulting installation
> is not behaving as expected, try using --config-settings editable_mode=compat.
> Please consult the setuptools documentation for more information.
> Discussion can be found at pypa/pip#11457
@ichard26
Copy link
Member

Original comment: #11457 (comment)

I can't edit the issue description as always, but as a regular reminder to all, the setup.py file itself is not deprecated. Even in 2025, you'll be able to use it to configure setuptools. What's changing that is that pip is not going to special case for setup.py while performing an editable install (i.e. pip won't be calling the CLI interface provided by setup.py such as setup.py develop).

However, at the bare minimum, please add a pyproject.toml with the build backend declared as it is the glue that enables various packaging tools, from old and new, to work together. Whether you migrate entirely off setup.py is a separate decision. If you are able, of course, you can certainly get rid of setup.py in many situations and benefit from other improvements in packaging, but that isn't required to address this specific deprecation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: editable Editable installations type: deprecation Related to deprecation / removal.
Projects
None yet
Development

No branches or pull requests