Skip to content

Instantly share code, notes, and snippets.

@jph00
Last active August 27, 2024 14:31
Show Gist options
  • Save jph00/7e48a85996189240f1629c9926a60183 to your computer and use it in GitHub Desktop.
Save jph00/7e48a85996189240f1629c9926a60183 to your computer and use it in GitHub Desktop.
Adding a minimal pyproject.toml - Claude chat

🧑 human (Aug 28, 2024, 12:01 AM)

DEPRECATION: Legacy editable install of coreg[dev]==0.14.0 from file:///... (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

I just started getting the above error when I pip install -e . of one of my own packages. I maintain a number of libs that I want people to be able to do editable installs of. I'd rather not require users add extra flags when doing editable installs of them. pyproject.toml doesn't support the features I need, so I have to use setup.py. Is there a way I can set this up?

🤖 assistant (Aug 28, 2024, 12:01 AM)

To address this issue while maintaining compatibility and ease of use for your users, you can make a few changes to your package setup. Here's a step-by-step approach:

  1. Keep using setup.py for now, but add a minimal pyproject.toml file to your project root.

  2. In the pyproject.toml, specify setuptools as the build system:

    [build-system]
    requires = ["setuptools>=64.0"]
    build-backend = "setuptools.build_meta"
  3. In your setup.py, ensure you're using setuptools.setup() and not the deprecated distutils.core.setup().

  4. If you haven't already, create a setup.cfg file to move some of the configuration out of setup.py. This helps with future compatibility.

  5. In setup.cfg, add an [options] section and specify zip_safe = False. This ensures that the package is installed in a way that's compatible with editable installs:

    [options]
    zip_safe = False
  6. If you're using any setup.py commands, consider moving them to setup.cfg or implementing them as setuptools entry points.

  7. Update your installation instructions to recommend using pip's latest version:

    pip install --upgrade pip
    pip install -e .
    
  8. If users still encounter issues, they can use the --config-settings editable_mode=compat flag:

    pip install -e . --config-settings editable_mode=compat
    

These changes should allow users to perform editable installs without additional flags in most cases, while also providing a fallback option for compatibility mode.

Remember to test these changes thoroughly with different pip versions and Python environments to ensure they work as expected.

By implementing these suggestions, you're moving towards a more modern packaging setup while still maintaining compatibility with setup.py and not requiring users to add extra flags for standard editable installs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment