Skip to content

Commit 9d2fbfc

Browse files
authored
fixed external editable in workspace (#19338)
1 parent 05b102e commit 9d2fbfc

File tree

2 files changed

+39
-8
lines changed

2 files changed

+39
-8
lines changed

conan/cli/commands/workspace.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,17 @@ def _install_build(conan_api: ConanAPI, parser, subparser, build, *args):
190190
ref = RecipeReference.loads(elem["ref"])
191191
for package_level in elem["packages"]:
192192
for package in package_level:
193-
if package["binary"] == "Build": # Build external to Workspace
194-
cmd = f'install {package["build_args"]} {profile_args}'
195-
ConanOutput().box(f"Workspace building external {ref}")
196-
ConanOutput().info(f"Command: {cmd}\n")
197-
conan_api.command.run(cmd)
198-
elif package["binary"] in ("Editable", "EditableBuild"):
199-
path = all_editables[ref]["path"]
200-
output_folder = all_editables[ref].get("output_folder")
193+
ws_pkg = all_editables.get(ref)
194+
is_editable = package["binary"] in ("Editable", "EditableBuild")
195+
if ws_pkg is None:
196+
if is_editable or package["binary"] == "Build": # Build external to Workspace
197+
cmd = f'install {package["build_args"]} {profile_args}'
198+
ConanOutput().box(f"Workspace building external {ref}")
199+
ConanOutput().info(f"Command: {cmd}\n")
200+
conan_api.command.run(cmd)
201+
else:
202+
path = ws_pkg["path"]
203+
output_folder = ws_pkg.get("output_folder")
201204
build_arg = "--build-require" if package["context"] == "build" else ""
202205
ref_args = " ".join(f"--{k}={getattr(ref, k)}"
203206
for k in ("name", "version", "user", "channel")

test/integration/workspace/test_workspace.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,34 @@ def packages(self):
574574
c.run("workspace build")
575575
assert "conanfile.py (pkga/0.1): Building pkga AND 0.1!!!" in c.out
576576

577+
def test_build_with_external_editable_python_requires(self):
578+
c = TestClient(light=True)
579+
c.save({"conanws.yml": "",
580+
"ext/conanfile.py": GenConanfile("ext", "0.1").with_package_type("python-require"),
581+
"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_python_requires("ext/0.1")
582+
})
583+
c.run("editable add ext")
584+
c.run("workspace add pkga")
585+
c.run("workspace build")
586+
c.assert_listed_binary({"pkga/0.1": ("8bca2eae7cd0d6b6da8d14f8c86069d89d265bd4",
587+
"EditableBuild")})
588+
c.assert_listed_require({"ext/0.1": "Editable"}, python=True)
589+
590+
def test_build_with_external_editable(self):
591+
c = TestClient(light=True)
592+
c.save({"conanws.yml": "",
593+
"ext/conanfile.py": GenConanfile("ext", "0.1").with_build_msg("BUILD EXT!"),
594+
"pkga/conanfile.py": GenConanfile("pkga", "0.1").with_requires("ext/0.1")
595+
})
596+
c.run("editable add ext")
597+
c.run("workspace add pkga")
598+
c.run("workspace build")
599+
assert "ext/0.1: WARN: BUILD EXT!" in c.out
600+
c.assert_listed_binary({"pkga/0.1": ("38f8a554b1b3c2cbb44321f0e731b3863359126c",
601+
"EditableBuild"),
602+
"ext/0.1": ("da39a3ee5e6b4b0d3255bfef95601890afd80709",
603+
"EditableBuild")})
604+
577605

578606
class TestNew:
579607
def test_new(self):

0 commit comments

Comments
 (0)