Hello,
The self.copy() function doesn't recognize none existing files. Maybe a file check could be implemented, which prints out a warning, if the file doesn't exist. Also a new option for self.copy() could be implemented which treats this warnings as errors. This feature will work only if a single file is copied.
If this behavior already exists, I am grateful for any information how to achieve it. Sure i can wrote my own checker in python, but such functionality already implemented in self.copy() would make conan more userfriendly.
Greetings
Niklas
The only problem I see is when copying patterns, you can't evaluate how many files should be copied. As self.copy is a generic method, I don't think providing different behavior according the input is a good idea, it will provide an ambiguous method IMO.
For Conan Center Index, the checks are made by hooks, they validate the package folder after running package() method. You can use it to validate your copied files too.
Hi @Nocccer
The self.copy() operates always over patterns, not filenames, so it is also a possibility that it doesn't match anything. This functionality is useful to implement package() methods that package *.a, *.lib, *.so, *.dylib, unconditionally, and only some of those will exist depending on the OS.
If you know exactly the filename you want to copy, maybe you could run a shutil.copy? Also, failing to package something is rarely an issue that the test_package functionality will not detect. As it is also possible that a pattern matches one file, but miss other files too, seems too much of an addition (in terms of impl + testing + docs, etc) for the provided value, I'd say it is not worth at this moment.
Hi @memsharded and @uilianries
I already thought that the implementation would be difficult or not consistently enough.
So thanks for the clarification. I will dig more into hooks and see if i find a solution that works for me.
If i should close the feature request, tell me.
I think I missed something that could be useful, the self.copy() return the list of files that have been copied. It can be easily checked directly in the recipe to verify that it actually copied some files, and error or warning at your will too.
https://github.com/conan-io/conan/pull/7389 tests and documents the return value of self.copy() which should be good for these possible extra checks.. Will be documented in Conan 1.28
Most helpful comment
I think I missed something that could be useful, the
self.copy()return the list of files that have been copied. It can be easily checked directly in the recipe to verify that it actually copied some files, and error or warning at your will too.