I think for recent setuptools, if you put a requirement in setup_requires, and you’re using a PEP 517-aware frontend (like the pep517 package, or recent pip), then anything in setup_requires gets converted into get_requires_for_build_wheel. So… if I’m right, then either setup_requires should work for your use case, or else, if it doesn’t, then that might mean that you actually do need the expensive packages already installed before you can call hooks.get_requires_for_build_wheel().
I also need it at runtime but there install_requires works so that’s not an issue
So… if I’m right, then either setup_requires should work for your use case
setup_requires is fundamentally incompatible with Cython because it uses easy_install, and easy_install’s sandbox breaks the Cython compiler. (it makes assumptions about module unloading & reloading that don’t hold true for native code modules like Cython and mess up global state) Unless someone decides to undeprecate and actually fix it, it’s sadly not an option. edit: some more info on the setup_requires issue: https://github.com/cython/cython/issues/2730
edit2: unless that changed in recent setuptools of course. but hasn’t setup_requires been deprecated? what’s the alternative for the future? I’ve always been pointed back to build-system.requires when I asked about that
edit3: I actually made a setuptools ticket for this https://github.com/pypa/setuptools/issues/1742 but closed it because build-system.requires was suggested as an alternative and at the time I didn’t know that it had this metadata analysis duration issue. so maybe I should just reopen that ticket
That specific statement is about setuptools. I don’t know what the setuptools project’s plans are for setup_requires, but the comment at the top of the build_meta code mentions it, so maybe they intend to (or already do) handle it in a more PEP 517 compatible way somehow.
Is setup_requires deprecated? I couldn’t see any mention of that in the setuptools documentation. As to fixing it, that’s something that would need to be raised on the setuptools tracker.
Overall, I think your issues here sound like they would be better explored on the setuptools tracker. If there’s something that needs a standards-level change, then that’s something that should be raised here, but I’d prefer it if the setuptools maintainers were able to confirm that they weren’t able to handle your requirements within the build tool before we escalated the discussion to standards that all build tools would be required to add support for.
Overall, I think your issues here sound like they would be better explored on the setuptools tracker.
I agree, I kind of forgot setup_requires is even an option due to its deprecation. But it seems it might most sense to figure out if maybe it shouldn’t be deprecated on the setuptools issue tracker, or if there’s some other alternative I’m not aware of. Will let you know how things turn out