Skip to content
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

fixing editables with root definition #13983

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conans/client/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ def _handle_node_editable(self, install_node):
conanfile_path = editable["path"]
output_folder = editable.get("output_folder")

# TODO: Check, this assumes the folder is always the conanfile one
base_path = os.path.dirname(conanfile_path)
base_path = base_path if conanfile.folders.root is None else \
os.path.normpath(os.path.join(base_path, conanfile.folders.root))
conanfile.folders.set_base_folders(base_path, output_folder)
output = conanfile.output
output.info("Rewriting files of editable package "
Expand Down
36 changes: 36 additions & 0 deletions conans/test/integration/editable/test_editable_layout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os
import textwrap

from conans.test.utils.tools import TestClient


def test_editable_folders_root():
""" Editables with self.folders.root = ".." should work too
"""
c = TestClient()
sub1 = textwrap.dedent("""
from conan import ConanFile

class Pkg(ConanFile):
name = "pkg"
version = "0.1"
def layout(self):
self.folders.root = ".."
self.folders.build = "mybuild"
self.cpp.build.libdirs = ["mylibdir"]
""")
sub2 = textwrap.dedent("""
from conan import ConanFile

class Pkg(ConanFile):
requires = "pkg/0.1"
def generate(self):
pkg_libdir = self.dependencies["pkg"].cpp_info.libdir
self.output.info(f"PKG LIBDIR {pkg_libdir}")
""")
c.save({"sub1/conanfile.py": sub1,
"sub2/conanfile.py": sub2})
c.run("editable add sub1")
c.run("install sub2")
libdir = os.path.join(c.current_folder, "mybuild", "mylibdir")
assert f"conanfile.py: PKG LIBDIR {libdir}" in c.out