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

add new members to ConanFileInterface #11868

Merged
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
24 changes: 24 additions & 0 deletions conans/model/conanfile_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def __hash__(self):
def __ne__(self, other):
return not self.__eq__(other)

@property
def recipe_folder(self):
return self._conanfile.recipe_folder

@property
def package_folder(self):
return self._conanfile.package_folder
Expand Down Expand Up @@ -82,3 +86,23 @@ def dependencies(self):
@property
def is_build_context(self):
return self._conanfile.context == CONTEXT_BUILD

@property
def conan_data(self):
return self._conanfile.conan_data

@property
def license(self):
return self._conanfile.license

@property
def description(self):
return self._conanfile.description

@property
def homepage(self):
return self._conanfile.homepage

@property
def url(self):
return self._conanfile.url
38 changes: 38 additions & 0 deletions conans/test/integration/graph/test_dependencies_visit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,41 @@ def generate(self):
# generate time, build-requires already available
assert "conanfile.py: GENERATE REQUIRE: cmake/0.1!!!" in client.out
assert "conanfile.py: GENERATE CMAKE: cmake/0.1!!!" in client.out


def test_dependency_interface():
"""
Quick test for the ConanFileInterface exposed
"""
c = TestClient()
conanfile = textwrap.dedent("""
from conans import ConanFile
class Pkg(ConanFile):
name = "dep"
version = "1.0"
homepage = "myhome"
url = "myurl"
license = "MIT"
""")
user = textwrap.dedent("""
from conan import ConanFile
class User(ConanFile):
requires = "dep/1.0"
def generate(self):
self.output.info("HOME: {}".format(self.dependencies["dep"].homepage))
self.output.info("URL: {}".format(self.dependencies["dep"].url))
self.output.info("LICENSE: {}".format(self.dependencies["dep"].license))
self.output.info("RECIPE: {}".format(self.dependencies["dep"].recipe_folder))
self.output.info("CONANDATA: {}".format(self.dependencies["dep"].conan_data))

""")
c.save({"dep/conanfile.py": conanfile,
"dep/conandata.yml": "",
"user/conanfile.py": user})
c.run("create dep")
c.run("install user")
assert "conanfile.py: HOME: myhome" in c.out
assert "conanfile.py: URL: myurl" in c.out
assert "conanfile.py: LICENSE: MIT" in c.out
assert "conanfile.py: RECIPE:" in c.out
assert "conanfile.py: CONANDATA: {}" in c.out