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

import from symbolic #bindirs, #libdirs, etc #6208

Merged
merged 3 commits into from Dec 20, 2019

Conversation

memsharded
Copy link
Member

@memsharded memsharded commented Dec 11, 2019

Changelog: Feature: imports functionality can import from "symbolic" names, preceded with @, like @bindirs, @libdirs, etc. This allows importing files from variable package layouts, including custom package_info() layouts (like cpp_info.bindirs = ["mybin"] can be used with src="@bindirs"), and editable package layouts

Docs: conan-io/docs#1547

Related: #4466

@memsharded memsharded added this to the 1.22 milestone Dec 11, 2019
Copy link
Contributor

@jgsogo jgsogo left a 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..

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:
Copy link
Contributor

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(....)
    ....

@memsharded
Copy link
Member Author

Reviewed and added extra error checking test.

@lasote
Copy link
Contributor

lasote commented Dec 20, 2019

Merging, I need this. but please don't forget the docs

@lasote lasote merged commit 2b45e63 into conan-io:develop Dec 20, 2019
@memsharded memsharded deleted the feature/imports_symbolic branch December 20, 2019 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants