How to pin version of spaces package?

Dependencies of HF spaces can be specified in requirements.txt.

When running the build (e.g., here), the docker image has a line:

RUN --mount=target=requirements.txt,source=requirements.txt 	pip install --no-cache-dir -r requirements.txt

that takes care of that. However, afterwards there is another line:

RUN pip install --no-cache-dir         gradio[oauth]==3.9.1         spaces==0.14.0

Which essentially implies that all versions specified in requirements.txt for the packages gradio, spaces and their dependencies are useless because they are overwritten here.
In this example, gradio is set to 3.9.1 because of the YAML config in but there is no way to specify the spaces version. In practice this means that I have no control over the version of spaces and its dependencies (e.g., httpcore) and all my spaces are now failing with:

  File "/home/user/.local/lib/python3.8/site-packages/httpcore/_sync/", line 161, in HTTP11Connection
    self, event: h11.Event, timeout: Optional[float] = None
AttributeError: module 'h11' has no attribute 'Event'

Which could normally easily be fixed by pinning httpcore==0.15. I checked past builds and spaces was also being installed there, however, the critical line was

RUN pip install --no-cache-dir         gradio[oauth]==3.9.1         spaces==0.12.0

which resulted in versions that were not conflicting.

Question: How do I properly pin the version of the spaces package?

Can’t believe that I’m the only person for whom this is causing trouble!

It seems that currently all deployed gradio webapps will use spaces==0.14.0 (now even spaces==0.15.0 that just became available). This spaces version relies e.g., on httpcore>=0.18.0, so effectively it seems to impose strong restrictions on which packages can be used

Just for future readers, I was able to resolve this issue by changing sdk_version of gradio in README.txt from 3.1.0 to 3.46.0. Then I just had to add h11==0.13.0 and now all my apps are back up

1 Like

thanks for the update, indeed using the latest Gradio will be the best recommendation.