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

Migrate from setup.py to pyproject.toml #1822

Open
sigurdvaa opened this issue Mar 8, 2023 · 6 comments
Open

Migrate from setup.py to pyproject.toml #1822

sigurdvaa opened this issue Mar 8, 2023 · 6 comments
Labels
priority: medium A problem affecting a core component for which there is a workaround
Milestone

Comments

@sigurdvaa
Copy link

sigurdvaa commented Mar 8, 2023

Migrate from setup.py to pyproject.toml

In the interest of the keeping the project up-to-date, we should consider migrating from setup.py to the new standard with pyproject.toml.

Python 3.12

In Python 3.12, the distutils module will be removed (PEP 632).
Setuptools has integrated a complete copy of distutils and does not depend on the standard library. Pip has silently been replacing distutils with setuptools for a long time.

Setuptools

Starting with PEP 621, the Python community selected pyproject.toml as a standard way of specifying project metadata. Setuptools has adopted this standard and will use the information contained in this file as an input in the build process.

Setuptools discourage the use of setup.py and that the majority of the command line interfaces are (or will be) deprecated.

If compatibility with legacy builds or versions of tools that don’t support certain packaging standards (e.g. PEP 517 or PEP 660), a simple setup.py script can be added to your project, while keeping the configuration in pyproject.toml

@satterly
Copy link
Member

satterly commented Mar 8, 2023

Perhaps I'm missing something here but we don't use distutils anywhere, right? So we are unaffected by the removal of distutils from Python 3.12. And there are only a few places where setup.py is called directly, of which there are simple replacement commands.

So actually adopting pyproject.toml is a separate issue and should not be confused with distools or setup.py deprecation.

And considering how much work would be involved in migrating to toml files across all the python repos for Alerta I don't think we have the time or resources right now. We can target this for a future release but for now I would prefer to let others go through the pain first and we can learn from their experiences.

@satterly satterly added the question Further information is requested label Mar 8, 2023
@sigurdvaa
Copy link
Author

Sorry if the issue in unclear - it's about consideration. There's probably more reasons for or against it than I have mentioned.

No, we don't use distutils. But both distutils and setuptools use the concept of setup.py. And with distutils gone and setuptools discouraging the use of setup.py and PEP 621 making pyproject.toml the new standard, we might want to to migrate away from setup.py, as support for it is dwindling. We don't have to migrate all python repos at once, but perhaps one at a time is more appropriate.

The adoptation might belong in separate issues, I have no opinion here.

I do agree that time and resources are better spent on other issues for now, but I think a migration probably have to be done sooner or later.

@satterly
Copy link
Member

@pantelis-karamolegkos
Copy link
Contributor

pantelis-karamolegkos commented Apr 6, 2023

Not sure is this relevant, but previously in 8.7.0 I built my custom image from the upstream alerta-web and installed my custom webhooks as follows

COPY webhooks-custom/ /app/webhooks-custom
RUN /venv/bin/pip install /app/webhooks-custom/my-webhook

This now fails with

Running setup.py install for alerta-my-webhook did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      running install
      /venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      error: could not create 'build': Permission denied
      [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

I worked around it by USER root (and then again USER 1001).

What caused this change? And why am I getting this deprecation warning since I am using pip

@satterly
Copy link
Member

@pantelis-karamolegkos Yes, it is relevant. The change is because Python is deprecating the use of setup.py. We need to remove all references to setup.py before we move to Python 3.12 (which btw has not been released yet).

@satterly satterly added priority: low A problem affecting a non-core component and removed question Further information is requested labels Jun 22, 2023
@satterly satterly added this to the Release 9.1 milestone Dec 20, 2023
@satterly satterly added priority: medium A problem affecting a core component for which there is a workaround and removed priority: low A problem affecting a non-core component labels Dec 20, 2023
@satterly
Copy link
Member

Good example here ... sphinx-doc/sphinx-intl#86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium A problem affecting a core component for which there is a workaround
Projects
None yet
Development

No branches or pull requests

3 participants