For context see these sympy and pytorch issues.
The pytorch issue is that people want to install nightly releases of pytorch but pytorch depends on sympy which depends on mpmath. Using pip install --pre torch results in installing mpmath 1.4.0 alpha 0 which is incompatible with the current release sympy 1.12. As a temporary fix sympy will release 1.12.1 alpha 1 with a fix for compatibility with mpmath 1.4.0 alpha 0. This is only a temporary fix because future prereleases of any of pytorch’s dependencies could break pip install --pre torch again.
My question here is basically the same as this SO question:
What is a good way with pip or other tools to install a prerelease of a package without installing prereleases of its dependencies?
If A depends on B and both A and B have recent prereleases I would like to install the prerelease of A but I want to get the normal release of B. Neither of these is what I want:
pip install A # full releases of both A and B
pip install --pre A # prereleases of both A and B
One solution is:
pip install B # normal release of B
pip install --pre A # prerelease of A
The downside of this is that I need to list all of A’s dependencies which might be a long list and also if A adds new dependencies in future then I need to update this. Project A could make a requirements.txt for this so that it is:
pip install -r requirements-A.txt
pip install --pre A
The problem with this is where do you put the requirements-A.txt file? You could put it in A’s codebase but then that’s no use for someone who is trying to install A from PyPI since they do not have A’s code. Also it seems unnecessary to make a redundant requirements.txt when all of the necessary information is already in A’s packaging metadata.
The solution suggested on SO is:
pip install 'A >= 1.0.dev1'
As I understand it including something that looks like a prerelease version in A’s version constraint will cause pip to look for prereleases of A but not of A’s dependencies which is what we want. This solution looks cryptic though and including a version 1.0 in the constraint suggests that 1.0 is somehow significant even though we would want to use this command to install new versions of A long after version 1.0. Probably this is as good as can be done if we need to encode this in a PEP 440 version constraint but I think that there should be a better way to spell this both for version constraints and for command line options.
Am I missing something obvious here or is A >= 1.0.dev1 the way to do this?
There were recent discussions I think about having something like:
pip install --only-dependencies A
pip install --pre A
It seems to me though that it is quite likely that someone using --pre actually might not want prereleases of all transitive dependencies. Whenever I have personally used --pre it was just because I wanted prereleases of one particular project.