Skip to content

[MNT]: Slowly move towards pyproject.toml? #23815

Closed

Description

@oscargus

Summary

I was considering moving parts of setup.py and setup.cfg to pyproject.toml. As I understand it, it is possible to mix and match, so whatever can be moved (I can move) will cooperate with what is left.

Since we have a setup.py with a bit of magic in it, I do no expect that I will be able to completely transition, but is it worthwhile even starting? Or do we expect that moving away from setup.py (which I guess should be the long term goal) requires more or less rewriting everything anyway, possibly changing packaging tool etc?

Proposed fix

No response

Activity

  1. ianthomas23 commented on Sep 7, 2022

    @ianthomas23
    Member

    I am in favour of this. The pybind11 work becomes much simpler if we at least replace setup_requires in setup.py with [build-system] in pyproject.toml. I was going to talk about it tomorrow's call.

    FWIW Bokeh has just made this transition.

  2. oscargus commented on Sep 7, 2022

    @oscargus
    MemberAuthor

    I gave it a quick try to just move over the more basic things and got stuck in that setupext could not be imported from setup.py anymore. I take it that it executes from another directory or something so that it does not find setupext.py.

    Copying the contents doesn't seem like the best way to solve it...

  3. ianthomas23 commented on Sep 7, 2022

    @ianthomas23
    Member

    A temporary environment is used to build a wheel which is then installed into your working environment. The temporary environment doesn't seem to have access to the full project directory.

    I have had success with:

    1. Removing the setup_requires section from setup.py

    2. New pyproject.toml containing

    [build-system]
    build-backend = "setuptools.build_meta"
    requires = [
        "certifi>=2020.06.20",
        "numpy>=1.19",
        "setuptools_scm>=7",
    ]
    
    1. Add the following line to setup.py just before import setupext:
    sys.path.append(str(Path(__file__).resolve().parent))
    

    so basically botching the sys.path so that it can find setupext.py.

  4. oscargus commented on Sep 12, 2022

    @oscargus
    MemberAuthor

    I've seen some problems with numpy versions. My guess is that using pyproject.toml somehow uses a different version of NumPy headers than possibly installed. For example, when installing using 1.22 installed I got an error about not matching API versions, which I didn't get with a plain setup.py install, while upgrading to 1.23 (and reinstalling, so not completely sure) I didn't. Seen similar problems with another package with a much simpler install procedure as well.

    Note that in both cases, the actual compilation happened in setup.py, so moving all the way may be a solution.

  5. tacaswell commented on Sep 12, 2022

    @tacaswell
    Member
  6. added this to the v3.7.0 milestone on Sep 12, 2022
  7. QuLogic commented on Sep 24, 2024

    @QuLogic
    Member

    This was completed as part of the Meson port in #26621.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions