Pyproject.toml build system requires pre-release

My pyproject.toml works fine for package standard release

[build-system]
requires = ["Cython >= 0.29", "setuptools >= 67", "wheel >= 0.40"]
build-backend = "setuptools.build_meta"

When I publish a pre-release on PyPI and install with pip install --pre my-package, also the build system requirements are used, like Cython 3*.b instead of 0.29

Is it possible to prevent using beta build requirements when the package itself is beta?

--pre is a global option, but there’s a few workarounds I can think of:

  • Publish wheels for pre-releases
  • Use a version specifier to “trick” pip into allowing pre-releases for your particular package only, e.g install my-package>=0.dev0
  • Download the package sdist with download --pre --no-deps and install it from path

Not exactly what you’re asking for, but one option would be to constrain the version of Cython it requires, e.g. Cython >= 0.29, <1, and extend it when Cython 3.0 is out and you can check that it works. This also protects it against whatever changes in Cython 4.0.

Of course, there’s always a downside: your package might fail to build on a new version of Python if a new version of Cython is needed to do so. Capping the supported Python version is not a good idea because of the way the resolver responds to that - see this thread.

(You’d still be opting into <1 pre-releases this way of course, which might not be what you want.)

this looks optimal for my use-case and thank you for sharing other options. It seems there is more than one way … :slight_smile: