conda-forge / conda-forge.github.io

The conda-forge website.
https://conda-forge.org
BSD 3-Clause "New" or "Revised" License
128 stars 274 forks source link

Explain oldest-supported-numpy #1778

Open BastianZim opened 2 years ago

BastianZim commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

chrisburr commented 2 years ago

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

ngam commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago
- rm pyproject.toml
- pip install . -vv --no-build-isolation --no-deps

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

h-vetinari commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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:

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 commented 2 years ago

fyi, xref: https://github.com/conda-forge/staged-recipes/pull/16514 & https://github.com/conda-forge/staged-recipes/pull/18982

hmaarrfk commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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: https://github.com/conda-forge/particula-feedstock/pull/13)

BastianZim commented 2 years ago

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

hmaarrfk commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

hmaarrfk commented 2 years ago

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