conan
conan copied to clipboard
[feature] Have `trim_conandata` not throw when there's no `conandata.yml`
What is your suggestion?
trim_conandata can be used inside a post_export hook instead of the export() method in recipes, but then we have no control over wether a recipe has an associated conandata.yml.
The fix is easy, just try: ... catch: it, but feels a bit dirty.
Ideally that could be skipped, but it's true that when used in the export method, it might be desirable to have it raise, so we need to give it a thought
Reproducing this is easy: Have a simple recipe without a conandata.yml and a post_export hook that simply calls trim_conandata. That is, this test should pass, which currently does not:
def test_trim_conandata_as_hook_without_conandata():
c = TestClient()
c.save_home({"extensions/hooks/hook_trim.py": textwrap.dedent("""
from conan.tools.files import trim_conandata
def post_export(conanfile):
trim_conandata(conanfile)
""")})
c.save({"conanfile.py": GenConanfile("pkg")})
c.run("export . --version=1.0")
assert c.exported_recipe_revision() == "a9ec2e5fbb166568d4670a9cd1ef4b26"
Have you read the CONTRIBUTING guide?
- [X] I've read the CONTRIBUTING guide