Skip to content

Commit 56241b0

Browse files
committed
fix incorrect inputs for relativize paths generator (conan-io#18561)
1 parent 253070c commit 56241b0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

conan/internal/api/install/generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def relativize_path(path, conanfile, placeholder, normalize=True):
254254
return path
255255
try:
256256
common_path = os.path.commonpath([path, conanfile.generators_folder, base_common_folder])
257-
if common_path == base_common_folder:
257+
if common_path.replace("\\", "/") == base_common_folder.replace("\\", "/"):
258258
rel_path = os.path.relpath(path, conanfile.generators_folder)
259259
new_path = os.path.join(placeholder, rel_path)
260260
return new_path.replace("\\", "/") if normalize else new_path

test/functional/command/test_install_deploy.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,21 @@ def deploy(graph, output_folder):
601601
c.run("install consumer --build=missing --deployer=mydeploy.py")
602602
data = c.load("consumer/some/sub/folders/generators/pkg-release-data.cmake")
603603
assert 'set(pkg_PACKAGE_FOLDER_RELEASE "${CMAKE_CURRENT_LIST_DIR}/../installed/pkg")' in data
604+
605+
606+
@pytest.mark.parametrize("absolute_path", [True, False])
607+
def test_deploy_output_absolute(absolute_path):
608+
# https://github.com/conan-io/conan/issues/18560
609+
c = TestClient()
610+
c.save({"pkg/conanfile.py": GenConanfile("pkg", "0.1").with_package_file("myfile.txt", "c"),
611+
"consumer/conanfile.txt": "[requires]\npkg/0.1"})
612+
c.run("create pkg")
613+
614+
# It is important to use the forward /myout in Windows, this was the breaking input
615+
out_path = f"{c.current_folder}/myout" if absolute_path else "myout"
616+
c.run("install consumer/conanfile.txt -s arch=x86_64 --deployer=full_deploy -g CMakeDeps "
617+
f'-of="{out_path}"')
618+
assert c.load("myout/full_deploy/host/pkg/0.1/myfile.txt") == "c"
619+
data = c.load("myout/pkg-release-x86_64-data.cmake")
620+
assert ('set(pkg_PACKAGE_FOLDER_RELEASE '
621+
'"${CMAKE_CURRENT_LIST_DIR}/full_deploy/host/pkg/0.1")') in data

0 commit comments

Comments
 (0)