conan.tools.files.AutoPackager
Available since: 1.42.0
The AutoPackager together with the package layouts feature, allow to automatically
package the files following the declared information in the layout() method:
It will copy:
- Files from - self.cpp.local.includedirsto- self.cpp.package.includedirs
- Files from - self.cpp.local.libdirsto- self.cpp.package.libdirs
- Files from - self.cpp.local.bindirsto- self.cpp.package.bindirs
- Files from - self.cpp.local.srcdirsto- self.cpp.package.srcdirs
- Files from - self.cpp.local.builddirsto- self.cpp.package.builddirs
- Files from - self.cpp.local.resdirsto- self.cpp.package.resdirs
- Files from - self.cpp.local.frameworkdirsto- self.cpp.package.frameworkdirs
The patterns of the files to be copied can be defined with the .patterns property of the AutoPackager instance.
The default patterns are:
packager = AutoPackager(self)
packager.patterns.include == ["*.h", "*.hpp", "*.hxx"]
packager.patterns.lib == ["*.so", "*.so.*", "*.a", "*.lib", "*.dylib"]
packager.patterns.bin == ["*.exe", "*.dll"]
packager.patterns.src == []
packager.patterns.build == []
packager.patterns.res == []
packager.patterns.framework == []
Usage:
from conan import ConanFile
from conan.tools.files import AutoPackager
class Pkg(ConanFile):
    def layout(self):
        ...
    def package(self):
        packager = AutoPackager(self)
        packager.patterns.include = ["*.hpp", "*.h", "include3.h"]
        packager.patterns.lib = ["*.a"]
        packager.patterns.bin = ["*.exe"]
        packager.patterns.src = ["*.cpp"]
        packager.patterns.framework = ["sframe*", "bframe*"]
        packager.run()