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
import from symbolic #bindirs, #libdirs, etc #6208
Conversation
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.
Something needed 👍 I would say it closes #5928 as it provides a much better way to solve the issue.
The only ther character I can think about is /
because it is invalid in a directory/file name, and it also doesn't make sense at the beginning of the string. Another alternative could be cpp_info.
.
conans/client/importer.py
Outdated
cpp_info_dirs = getattr(cpp_info, dir_name) | ||
except AttributeError: | ||
raise ConanException("Import from unknown package folder '#%s' % dir_name)") | ||
for info_dir in cpp_info_dirs: |
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.
You can build a list of paths, and then avoid duplicating this code:
if src.startswith("#"):
...
source_dirs = cpp_info_dirs
else:
source_dirs = [src]
for source_dir in source_dirs:
files = file_copier(....)
....
Reviewed and added extra error checking test. |
Merging, I need this. but please don't forget the docs |
Changelog: Feature:
imports
functionality can import from "symbolic" names, preceded with @, like @bindirs, @libdirs, etc. This allows importing files from variable package layouts, including custompackage_info()
layouts (likecpp_info.bindirs = ["mybin"]
can be used withsrc="@bindirs"
), and editable package layoutsDocs: conan-io/docs#1547
Related: #4466