Skip to content

Feature/workspace py requires#19851

Draft
memsharded wants to merge 27 commits intoconan-io:develop2from
memsharded:feature/workspace_py_requires
Draft

Feature/workspace py requires#19851
memsharded wants to merge 27 commits intoconan-io:develop2from
memsharded:feature/workspace_py_requires

Conversation

@memsharded
Copy link
Copy Markdown
Member

Changelog: Feature: Allow python_requires in workspace
Docs: https://github.com/conan-io/docs/pull/XXXX

Close #19793

This builds on top of #19797, and still super-dirty.
It is not guaranteed to be moved forward, I am thinking that maybe workspaces should be focused on C/C++ work, not simultaneously modifying some python-requires, which are tools for recipes, bug workspaces are focused on the C/C++ development experience.

A python-require to work on it could be added as globally editable relatively easy. So not sure if the complexity added by this PR would be worth (the way it works to solve chicken-and-egg problem is very subtle, by sharing a common object that gradually gets the workspace package definitions incrementally while resolving them, so that means that python requires should always come first, but this is fragile.

@memsharded memsharded requested a review from AbrilRBS April 13, 2026 15:34
self.conan_data = self._conan_load_data()
self._conan_api = conan_api
self.output = ConanOutput(scope=f"Workspace '{self.name()}'")
self._loader = None
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only change to workspace.py is instead of declaring and creating its own (and incomplete) loader, it gets the object from the caller

packages[reference] = pkg
# This needs to be incremental, in the loop, so loaded ones are made available
# for next iterations that might require python-requires in their ws.load_conanfile
editable_packages.edited_refs[reference] = pkg
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the core change/proposal. Incremental adding to the editable_packages object, that is shared by ConanProxy, RangeResolver, the packages that are loaded from the workspace.

Comment thread conan/api/conan_api.py
# This is caching too!
loader = ConanFileLoader(pyreq_loader, conanfile_helpers)
return proxy, range_resolver, loader, None
ws_packages = self._conan_api.workspace._load_packages(loader, editable_packages) # noqa
Copy link
Copy Markdown
Member Author

@memsharded memsharded Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implements the chicken and egg, instead of doing it in one shot in self._conan_api.workspace.packages(), it executes over the editable_packages object, so it adds incrementally to it, so the ConanProxy and RangeResolver immediately get knowledge of the added editables in the workspace, so they can resolve to them if necessary, like former python-requires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Conan Workspace Doesn't Load Pyrequires

4 participants