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

Explain oldest-supported-numpy #1778

Open
BastianZim opened this issue Jun 14, 2022 · 19 comments
Open

Explain oldest-supported-numpy #1778

BastianZim opened this issue Jun 14, 2022 · 19 comments

Comments

@BastianZim
Copy link
Member

BastianZim commented Jun 14, 2022

Where should the content be added?

FAQ

What should be added?

NumPy introduced oldest-supported-numpy: https://github.com/scipy/oldest-supported-numpy

This can be used by packages instead of specifying a NumPy range when building.

The package doesn't exist in conda-forge and instead numpy should be used without any versions specified.

Additional information

https://gitter.im/conda-forge/conda-forge.github.io?at=62a8fc44deea5616bbf9b99c

@ngam
Copy link
Contributor

ngam commented Jun 15, 2022

oldest-supported-numpy shows up in pyproject.toml too; in that case, either a patch is needed or alternatively deleting --no-deps from the python install call so that pip can install/find numpy. The patch is safer

@ngam
Copy link
Contributor

ngam commented Jun 15, 2022

Maybe we should consider making an alias package, name it oldest-supported-numpy and set it equal exactly to numpy

@chrisburr
Copy link
Member

Maybe a linter rule in conda-smithy would be better if oldest-supported-numpy is found in the recipe?

@ngam
Copy link
Contributor

ngam commented Jun 15, 2022

Maybe a linter rule in conda-smithy would be better if oldest-supported-numpy is found in the recipe?

Yes, definitely. The alias package idea is really a bad hack. It's just that we already have whatever oldest-supported-numpy is supposed to do implemented seamlessly in conda-forge, so we could simply just replace occurrences of oldest-supported-numpy with numpy (e.g. in a patch) and all should be good. If that could be done with a linter, even better!

@h-vetinari
Copy link
Member

I actually think the wrapper (or an empty package that just tells pip oldest-supported-numpy is installed) could be an interesting idea. I'm patching pyproject.toml files on a couple of feedstocks, and it's painful. If a wrapper package would allow avoiding that, it would be very nice!

@hmaarrfk
Copy link
Contributor

- rm pyproject.toml
- pip install . -vv --no-build-isolation --no-deps

why not adapt your build script to completely remove pyproject.toml

@h-vetinari
Copy link
Member

why not adapt your build script to completely remove pyproject.toml

I've started doing that, but it's still a bandaid IMO. More and more functionality ecosystem-wide is moving into pyproject.toml (e.g. scipy starting to require meson to build), so it would be nice to be able to install packages out-of-the box (as in the staged-recipes example-package) just by providing the right dependencies.

@chrisburr
Copy link
Member

more functionality ecosystem-wide is moving into pyproject.toml

Longer term I think we should start using pyproject.toml to improve the update of recipes (likely using grayskull + some conservative logic to compare to the previous recipe). In this case grayskull can be adapted to convert oldest-supported-numpy to something suitable for conda-forge.

@BastianZim
Copy link
Member Author

For now, we can just add it to the matching as a new quirk: https://github.com/conda-incubator/grayskull/blob/main/grayskull/strategy/config.yaml

@eli-schwartz
Copy link

why not adapt your build script to completely remove pyproject.toml

Because that would be like removing setup.cfg / setup.py when they specify oldest-supported-numpy in setup_requires in a pre-PEP 517/518 package. Removing huge swathes of the build system because one tiny part of it includes a version pin will just break everything because, well, huge swathes of the build system are there.

pip cannot install anything unless it either:

  • uses setuptools
  • has a pyproject.toml for better or worse

Depending on the build backend, it may be possible to run that directly instead. e.g. flit build --format wheel / poetry build --format wheel / python setup.py bdist_wheel. This is a problem for things like Meson (SciPy) where the build backend doesn't have a frontend CLI (and meson install does not handle dist-info yet).

@ngam
Copy link
Contributor

ngam commented Jun 16, 2022

@hmaarrfk
Copy link
Contributor

Removing huge swathes of the build system

I think this is somewhat overblown. Much of the dependencies are rewritten in the meta file. Pyproject.toml may help in a pypi context, but in a conda forge centric context, it somewhat duplicates alot of the effort of the CIs and docker.

Maybe I'm not so versed in the more recent additions to pyproject.toml, but i recall it was made to help declare build time dependencies, as such, this is duplicated in the meta file, and can likely safely be removed, or replaced by a shim for conda-forge purposes.

@eli-schwartz
Copy link

eli-schwartz commented Jun 18, 2022

Maybe I'm not so versed in the more recent additions to pyproject.toml, but i recall it was made to help declare build time dependencies, as such, this is duplicated in the meta file

There's a new PEP that says that the meta file is now pyproject.toml, in the [project] section.

There's (experimental?) support for "no setup.cfg, just pyproject.toml" in setuptools. Flit and poetry never use anything else. Meson-python (used by e.g. SciPy) never uses anything else. Other build backends will follow if they haven't already.

So yes, that file is now a hard requirement a lot of the time.

EDIT: see https://peps.python.org/pep-0621/

@ngam
Copy link
Contributor

ngam commented Jun 18, 2022

So yes, that file is now a hard requirement a lot of the time.

That's my understanding too. Well, at least in the "recommended" setup (i.e. using setup.cfg AND pyproject.toml instead of setup.py). I am rather inexperienced in this area, so I have no idea if "recommended" is legit or I just happen to remember it this way.

but i recall it was made to help declare build time dependencies, as such, this is duplicated in the meta file, and can likely safely be removed, or replaced by a shim for conda-forge purposes.

I think you're correct about the build time thing, but the larger problem is that newer projects may simply fail if pyproject.toml is deleted (not that it is actually of any use in conda-forge). For example, if a package uses setup.cfg, then it must also include pyproject.toml; so if we delete pyproject.toml and run {{ PYTHON }} -m pip install . -vv, we get this error:

ERROR: Directory '.' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.

(example implementation: conda-forge/particula-feedstock#13)

@BastianZim
Copy link
Member Author

Just to add: I have seen some projects now that only have a pyproject.toml so removing is not an option anymore.

@hmaarrfk
Copy link
Contributor

Ok. It seems to have evolved to be more than just build system declaration.

Does pip have a flag to ignore the build system stuff? Does the --no-build-isolation flag do what you need?

@ngam
Copy link
Contributor

ngam commented Jun 21, 2022

Does the --no-build-isolation flag do what you need?

No, but even if it did, the problem is now more complicated anyway, I just wanted to give you a minimal live example of it failing.

@ngam
Copy link
Contributor

ngam commented Jun 22, 2022

Here is one with only pyproject.toml: conda-forge/staged-recipes#19364 (btw, pls merge it if you can, thanks!)

@hmaarrfk hmaarrfk mentioned this issue Jul 11, 2022
3 tasks
@hmaarrfk
Copy link
Contributor

I'm sorry, that project doesn't actually have any required dependencies nor does it use oldest-supported-numpy.

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

No branches or pull requests

6 participants