-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Support for PEP 735 dependency groups #11766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @cthoyt, thanks for opening this issue. I don't think we will support this soon since it requires a lot of extra work from our side and we are focusing ourselves on different features currently. However, this use case will be a really good fit for the work we are doing on #11710. Once that PR gets merged, you will be able to write something like: version: 2
build:
jobs:
install:
- pip install --dependency-groups=test,typing |
Happy to test as well. I'm having the same problem (build) at this PR: |
You should be able to test this out, #11710 was released this week and it seems to behaving well so far. We'd be curious to know how this goes and if this is an easy way to support custom/alternative installation methods. |
It seems that |
I guess a more general question is: how does one use the new feature? |
Yeah we don't have any serious docs on this yet, you'll have to glue some pieces together here. I haven't followed dependency groups in pip, but if it's a case of pip being out of date, you might also need to upgrade pip in your own project for now. The version we install might be lagging a little bit. For uv, support isn't built in but can be achieved with some extra setup: In the end, you should have something like: build:
jobs:
install:
- pip install --dependency-groups=tests,typing That is just a rough example though. |
Thank you, @agjohnson. This seems to have worked: build:
os: ubuntu-22.04
tools:
python: "3.12"
jobs:
install:
- pip install .
- pip install dependency-groups
- pip-install-dependency-groups doc |
For anyone wondering how to do it with For mkdocs:
and for sphinx:
The Makefile with the html command can be seen here: |
Thanks for sharing these examples. I think the only actionable could be to write these examples in our documentation at https://docs.readthedocs.io/en/latest/build-customization.html |
Isn't it already the case ? |
Well, yes, but that example doesn't mention/use dependency groups. |
I want to get the documentation building on RTD. The YAML configuration is based on the one from the RTD documentation[1] and some dependency-group-related suggestions from [2]. [1] https://docs.readthedocs.com/platform/latest/build-customization.html#install-dependencies-with-uv [2] readthedocs/readthedocs.org#11766 (comment)
I want to get the documentation building on RTD. The YAML configuration is based on the one from the RTD documentation[1] and some dependency-group-related suggestions from [2]. [1] https://docs.readthedocs.com/platform/latest/build-customization.html#install-dependencies-with-uv [2] readthedocs/readthedocs.org#11766 (comment)
For anyone who wants pull request previews to build with .PHONY: dev
dev: ## Install required Python, create Python virtual environment, and install package requirements
@uv python install ">=3.11,<3.13"
@uv venv
@uv sync
.PHONY: rtd-prepare
rtd-prepare: ## Prepare environment on Read the Docs
asdf plugin add uv
asdf install uv latest
asdf global uv latest
.PHONY: rtd-pr-preview
rtd-pr-preview: rtd-prepare dev ## Build pull request preview on Read the Docs
cd $(DOCS_DIR) && $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/ The command
|
@stevepiercy I'm a little confused with your example and I'm not sure I follow it completely. Is it using "dependency groups"? I understand it doesn't, right? We already have an example documented to use This issue is about using dependency groups either with |
@humitos no, it doesn't. I found this issue when looking for a way to use pull request previews with uv, not build the published docs. I derived my example from commands both in this issue and the docs. Sorry for hijacking the issue in my haste, but it seemed useful. Maybe we should create a new issue from my example? |
Why you would have different build processes? That could be an issue, since everything could work fine in the PR, but break in production. |
@humitos sorry, I wasn't clear again. My build and PR preview processes are the same. I was only looking for examples to use, and there were none for PR previews. Maybe a link on this page to example configuration that only exists in the build docs would close the loop? Anyway, the example configuration in your published docs uses |
This PR switches from using optional-dependencies to dependency-groups for several development dependencies This depends on: - tox-dev/tox#3409 - astral-sh/uv#8272 - astral-sh/uv#8590 - astral-sh/uv#8969 - astral-sh/uv#10861 - astral-sh/uv#11686 (actually incorporated in uv 0.6.8) - readthedocs/readthedocs.org#11766, will be solved by readthedocs/readthedocs.org#11710
What's the problem this feature will solve?
PEP 735 introduced dependency groups, which are complementary to optional dependencies in that dependency groups might not correspond to features in the package, but rather be something like development or release dependencies.
You can install something with dependency groups like this:
$ pip install --dependency-groups=tests,typing
ReadTheDocs currently supports specifying optional dependencies (c.f., https://docs.readthedocs.io/en/stable/config-file/v2.html#packages) with configuration like the following, where
docs
probably hassphinx
,sphinx-rtd-theme
, and other sphinx plugins.Describe the solution you'd like
I'd like an additional configuration in the
install
dictionary that works similar toextra_requirements
that would correspond to dependency groups. Let's say I have used the PEP 735 definition of my docs, like in this abbreviated pyproject.toml:then I would want to define it with an alternate key, like
dependency_groups
(just a suggestion for the name):Alternative solutions
This approach isn't required to get the intended results, which is of course to install the right extra dependencies to get my docs to build. However, the main goal is to better organize my metadata, and not to expose sphinx as an "extra" on PyPI, which doesn't exactly fit the spirit of extras/optional dependencies
Another in-progress solution (mentioned in #11766 (comment)) is #11710, which will allow for:
Additional context
This is motivated by recent improvements in pip, uv, and tox! I have an (almost) working demo in my cookiecutter project which shows how to update configuration properly to support this cthoyt/cookiecutter-snekpack#32
I am not familiar at all with the RTD stack, but if there's a way I can contribute to coding this up, please let me know :)
Nitty-gritty
Here are a few places which probably would be part of a theoretical implementation:
readthedocs.org/readthedocs/config/models.py
Lines 77 to 81 in 404d82a
I'd simply add a new slot
dependency_groups
herereadthedocs.org/readthedocs/doc_builder/python_environments.py
Lines 66 to 67 in 404d82a
here's how I'd update this:
As a minor note, I would also do a bit of refactoring to store all of the args into the list and then splat all of them into
run()
The text was updated successfully, but these errors were encountered: