Skip to content

Conversation

Copy link

Copilot AI commented Jan 5, 2026

AutoPackager has been removed in Conan 2.x. The recommended migration path is explicit file copying in the package() method using conan.tools.files.copy().

Changes

  • Removed AutoPackager import from conan.tools.files
  • Replaced AutoPackager.run() with explicit copy() calls for:
    • Headers: *.h, *.hppinclude/
    • Libraries: *.so*, *.a, *.lib, *.dyliblib/
    • Binaries: *.dllbin/
    • Licenses: LICENSE*licenses/

Implementation

def package(self):
    copy(self, pattern="LICENSE*", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
    copy(self, pattern="*.h", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"))
    copy(self, pattern="*.hpp", dst=os.path.join(self.package_folder, "include"), src=os.path.join(self.source_folder, "include"))
    copy(self, pattern="*.so", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
    copy(self, pattern="*.so.*", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
    copy(self, pattern="*.a", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
    copy(self, pattern="*.lib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
    copy(self, pattern="*.dylib", dst=os.path.join(self.package_folder, "lib"), src=self.build_folder, keep_path=False)
    copy(self, pattern="*.dll", dst=os.path.join(self.package_folder, "bin"), src=self.build_folder, keep_path=False)

Follows Conan 2.x conventions: absolute destination paths with os.path.join(self.package_folder, ...) and keep_path=False for flattening library directories.

Original prompt

Replace the AutoPackager, since this has been removed in newer versions of Conan.

conan.tools.files.AutoPackager
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.includedirs to self.cpp.package.includedirs

Files from self.cpp.local.libdirs to self.cpp.package.libdirs

Files from self.cpp.local.bindirs to self.cpp.package.bindirs

Files from self.cpp.local.srcdirs to self.cpp.package.srcdirs

Files from self.cpp.local.builddirs to self.cpp.package.builddirs

Files from self.cpp.local.resdirs to self.cpp.package.resdirs

Files from self.cpp.local.frameworkdirs to 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 conans 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()

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 5, 2026 13:14
Co-authored-by: jellespijker <8535734+jellespijker@users.noreply.github.com>
Co-authored-by: jellespijker <8535734+jellespijker@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace AutoPackager for newer Conan compatibility Replace deprecated AutoPackager with explicit copy() calls Jan 5, 2026
Copilot AI requested a review from jellespijker January 5, 2026 13:20
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.

2 participants