You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Editables api allows for using custom filenames instead of conanfile.py:
$ conan editable add pyreq.py
Reference 'python_requires/local' in editable mode
$ conan editable list
python_requires/local
Path: /tmp/c/pyreq.py
In 2.11.1, conan workspace also allowed for workspace_api.load(folder / 'pyreq.py') - yet after adapting for #17688 's scheme of self.load_conanfile(folder / 'pyreq.py'), Conan attempts to chain the specified path with conanfile.py:
ERROR: Error loading conanfile at '/tmp/c/pyreq.py/conanfile.py': /tmp/c/pyreq.py/conanfile.py not found!
It's not critical for us, as we only have a single python_requires file named customly, but I think it would be nice if WS and good ol' editables followed the same policy on this.
I bypassed the issue with a crude hack in 2 files (amending load_conanfile() proved to be not enough), but there probably is a better way.
diff --git a/conan/api/subapi/workspace.py b/conan/api/subapi/workspace.py
index 446d08347..f419d4e7d 100644
--- a/conan/api/subapi/workspace.py+++ b/conan/api/subapi/workspace.py@@ -109,7 +109,9 @@ class WorkspaceAPI:
editables = self._ws.editables()
editables = {RecipeReference.loads(r): v.copy() for r, v in editables.items()}
for v in editables.values():
- path = os.path.normpath(os.path.join(self._folder, v["path"], "conanfile.py"))+ path = os.path.normpath(os.path.join(self._folder, v["path"]))+ if os.path.isdir(path):+ path = os.path.join(path, "conanfile.py")
if not os.path.isfile(path):
raise ConanException(f"Workspace editable not found: {path}")
v["path"] = path
diff --git a/conan/internal/model/workspace.py b/conan/internal/model/workspace.py
index 13f89e3ce..438f7cdbb 100644
--- a/conan/internal/model/workspace.py+++ b/conan/internal/model/workspace.py@@ -78,7 +78,9 @@ class Workspace:
return self.conan_data.get("products", [])
def load_conanfile(self, conanfile_path):
- conanfile_path = os.path.join(self.folder, conanfile_path, "conanfile.py")+ conanfile_path = os.path.join(self.folder, conanfile_path)+ if os.path.isdir(conanfile_path):+ conanfile_path = os.path.join(conanfile_path, "conanfile.py")
from conans.client.loader import ConanFileLoader
from conan.internal.cache.home_paths import HomePaths
from conan.internal.conan_app import ConanFileHelpers, CmdWrapper
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
There is a reason for the new Workspace feature to always use the conanfile.py name. It is because the workspace model is very intended to work with folders. The commands conan workspace add/open and conan workspace remove can dynamically add new things to the workspace, even doing a git clone of the repo that contains the specific dependency. At the moment it is not being very aggressive and removing files from the workspace, but a potential counterpart to the workspace open command that would be a workspace close command will need to actually remove files.
I am not saying it will be impossible to allow other names rather than conanfile.py, but it would make things less consistent and likely more fragile if things are not structured in folders. So maybe if your only case is one single python_requires, it sounds that it would be better to stay at the moment with the folders approach.
What is your suggestion?
Editables api allows for using custom filenames instead of
conanfile.py
:In
2.11.1
,conan workspace
also allowed forworkspace_api.load(folder / 'pyreq.py')
- yet after adapting for #17688 's scheme ofself.load_conanfile(folder / 'pyreq.py')
, Conan attempts to chain the specified path withconanfile.py
:It's not critical for us, as we only have a single
python_requires
file named customly, but I think it would be nice if WS and good ol' editables followed the same policy on this.I bypassed the issue with a crude hack in 2 files (amending
load_conanfile()
proved to be not enough), but there probably is a better way.Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: