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

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

Open
oscargus opened this issue Sep 7, 2022 · 5 comments
Open

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

oscargus opened this issue Sep 7, 2022 · 5 comments

Comments

@oscargus
Copy link
Contributor

oscargus commented Sep 7, 2022

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

@ianthomas23
Copy link
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.

@oscargus
Copy link
Contributor Author

oscargus commented Sep 7, 2022

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...

@ianthomas23
Copy link
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.

@oscargus
Copy link
Contributor Author

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.

@tacaswell
Copy link
Member

@oscargus See https://github.com/matplotlib/matplotlib/pull/23829/files#r968896893 for the numpy API version issue.

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

No branches or pull requests

4 participants