-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conan 2 workspaces #15992
Comments
I am very keen on seeing workspaces being introduced! Currently, I can think of two features that I would like to have. Single build command for building multiple packages in a workspaceI have created a fork of your own fork and implemented a very hacky solution of this: https://github.com/aander80/memsharded-conan/tree/feature/workspace. I believe you should be able to clone my fork, checkout The idea is to have a command like On-the-fly editables and overriding dependenciesI have been looking into Cargo workspaces for Rust. There you have the wonderful feature of setting dependencies for the workspace, and in each package/crate re-use the workspace dependencies. Example here:
I imagine something similar would be very powerful for conan, where you can select to override dependencies in a workspace. When you are working with large projects with many commits being merged every day and with dynamic versioning where each commit gets a unique version, managing static editables will be tough to manage (especially since just creating a new commit during local development would force you to change your editables). To solve this, it would be very useful if you have multiple repos, add them to a workspace, and the dependencies would be automatically injected in the dependency graph as editables, without having to configure them statically as editables in the conan cache. In my example, let's assume I have two repos:
I understand that this could be very tricky to solve since you might have multiple versions and contexts of packages; some might require For me I think a key feature for simplicity is to have on-the-fly editables that are only injected in the workspace/for the current command. I hope I managed to make myself understood in my ramblings here! 😄 |
Hi @aander80 Thanks for your feedback. Regarding your first point:
This can be done today with the This will be most likely improved with a About your second point, I think it is very aligned with our current vision, and I have already started to work on it, I have some working code in a branch. Keep tuned, I will try to share when possible to start gathering feedback, I will share it in this thread. |
Thanks for your reply! I am happy to hear about your vision, looking forward to seeing this implemented some day! 😄 It is also great to hear building multiple editables is possible already today, that should make multirepo development easier already now, although it might require a few extra commands! |
Hi everyone, This is finally happening, we have the first PR for next Conan 2.10: #17272 Feedback is very welcome, if you can run from my source branch, new |
#17272 has been merged, it will be in next Conan 2.10. It needs env-var defined |
I've just done some poking around the new command and I have a few initial thoughts
|
I think I've been able to come up with a reasonable solution for local development for point 5 (and probably point 4) above. You can add each project in the mono repo using fetch content with Here is some cmake that got the job done in my little test repo: cmake_minimum_required(VERSION 3.15)
project(monorepo CXX)
include(FetchContent)
function(add_project PROJECT_PATH_AND_NAME)
FetchContent_Declare(
${PROJECT_PATH_AND_NAME}
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/${PROJECT_PATH_AND_NAME}
SYSTEM
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(${PROJECT_PATH_AND_NAME})
endfunction()
add_project(project1)
add_project(project2)
add_project(app) You have to set the output directory for each sub project as well like so: set_target_properties(project2
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
) Ideally they would be set to the following, but I can't figure out how to get conan to play nice with this. set_target_properties(project2
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
) |
Thanks very much for the feedback @mattangus. I'll follow up on the other items when possible, but looking good, so thanks very much! |
Hi everyone, we keep doing progress in workpaces:
This is still an "incubating feature", but doing progress, please keep the feedback coming, so we can continue maturing it. As quick feedback about the It might be worth to create a dedicated ticket for it, and discuss it in detail there. |
Proposed some very early stage poc for the monolithic CMake build in: #17675 Running from that PR branch:
|
Update: PR #17688 has proposed a new syntax for the import os
from conan import Workspace
class MyWorkspace(Workspace):
def name(self):
return "myws"
def add(self, ref, path, *args, **kwargs):
self.output.info(f"Adding {ref} at {path}")
super().add(ref, path, *args, **kwargs)
def remove(self, path, *args, **kwargs):
self.output.info(f"Removing {path}")
return super().remove(path, *args, **kwargs) And with access to the underlying |
May I please ask for something like |
Thanks for the feedback @Artalus The warnings will not be silented, because what is even worse than the inconvenience of yellow warnings in the output is users complaining because the release broke something. But I agree those seems too many, it is not intended that there are those too many, how is that happening? Can you share some code or something that reproduce that? The idea is that you get only one per |
... which is why the silencing would be hidden not by one, but by two "i agree" envvars 😉
This one is mostly on me; we have a
So it will get better once I refactor out the API initialization. |
We know. The problem is that the Workspace intercepts things very early. So early that it can define its own CONAN_HOME for the current workspace, which in turns affect to all the configuration loaded from |
Important update: #17675 was merged, it will be in next Conan 2.13 (still as incubating) This is a major improvement in workspaces. Feedback to get it out of incubating very necessary, please give it a try and report (we will update the docs "incubating" section) |
I am trying to apply def editables(self):
editables_result = {}
todos = [TARGET_PROJECT]
while todos:
cf = Path(todos.pop()).as_posix()
conanfile = self.load_conanfile(cf)
editables_result[f"{conanfile.name}/editable"] = {"path": f}
todos.extend(__something_to_get_direct_dependencies_of(conanfile)) ...But the only two interfaces I could think of seem to be unavailable during
I could probably call What are my options @memsharded ? |
Following up in a dedicated issue: #17844 |
This ticket purpose is to gather and centralize discussion of all the other opened tickets, now that we are starting to resume work on workspaces for Conan 2.
layout()
definition.conanrc
. If considered, this would be a workspace feature.The text was updated successfully, but these errors were encountered: