-
Notifications
You must be signed in to change notification settings - Fork 985
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
#16427. Make MSBuildDeps generation with deployer relocatable #16441
#16427. Make MSBuildDeps generation with deployer relocatable #16441
Conversation
…ed props file when deployer is used. Copied the logic from conan\tools\cmake\cmakedeps\templates\target_data.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @stgatilov
This looks good. It would be necessary to add some test to cover this case. I can help adding those tests if you want or feel it is too much, but if you want to try, you can start from https://github.com/conan-io/conan/blob/develop2/test/functional/command/test_install_deploy.py, maybe starting from some test like test_deploy_reference
Note these tests only verify the generated file correctness, but not necessarily use the files in a real build. If you test it also for your full use case, that would be useful, but I don't think it is necessary to add a full building test to the suite to cover this.
…in props with deployer, and absolute paths without deployer. Note: this test does not invoke msbuild, and thus does not depend on MSVC / Windows.
I added a simple test. Since my goal was a test without msbuild, the tests in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is looking good enough, it would benefit from some refactors as parameterizing the test instead of a for
, but don't worry about it, we ca can do it later.
The only problem is the test is failing in other platforms than Windows:
# path should be absolute, since conan cache does not move with project
> assert os.path.isabs(value)
E AssertionError: assert False
E + where False = <function isabs at 0x7f9e62578a40>('tmp/tmp9yzuhr1lconans/path with spaces/.conan2/p/b/libhb1f8faf955e10/p')
E + where <function isabs at 0x7f9e62578a40> = <module 'posixpath' (frozen)>.isabs
E + where <module 'posixpath' (frozen)> = os.path
It would be perfectly fine to add a @pytest.mark.skipif(platform.system() != "Windows", reason="Requires Windows")
to the test so it only runs in WIndows
Thanks very much for contributing this! |
Changelog: Feature: Make
MSBuildDeps
generation with deployer relocatable.Docs: Omit
Close #16427
develop
branch, documenting this one.I have copied the relativize_path logic from CMakeDeps, I can't say I fully understand its implementation though.
As far as I understand, paths should be relativized when deployer is present but kept absolute if package is in conan cache. I have not found in the code where this decision happens, but I have tested locally that paths are relative with deployer but absolute without it (even though everything is on the same disk letter).
Please advise where to add test if it is necessary. As far as I see, there are two tests which check that output with deployer is relocatable (
tests/functional/command/test_install_deploy.py
). If I should make a similar test for MSBuildDeps, where should I put it?