Core guidelines — conan 2.4.0 documentation (2024)

Good practices

  • build() should be simple, prepare the builds in generate() instead:The recipes’ generate() method purpose is to prepare the build as much as possible.Users calling conan install will execute this method, and the generated files shouldallow users to do “native” builds (calling directly “cmake”, “meson”, etc.) as easy as possible.Thus, avoiding as much as possible any logic in the build() method, and moving it tothe generate() method helps developers achieve the same build locally as the one thatwould be produced by a conan create build in the local cache.

  • Always use your own profiles in production, instead of relying on the auto-detected profile,as the output of such auto detection can vary over time, resulting in unexpected results.Profiles (and many other configuration), can be managed with conan config install.

  • Developers should not be able to upload to “development” and “production” repositories in the server.Only CI builds have write permissions in the server. Developers should only have read permissions andat most to some “playground” repositories used to work and share things with colleagues,but which packages are never used, moved or copied to the development or production repositories.

  • The test_package purpose is to validate the correct creation of the package, not for functional testing. The test_package purpose is to check that the package has been correctly created (that is,that it has correctly packaged the headers, the libraries, etc, in the right folders), not thatthe functionality of the package is correct. Then, it should be kept as simple as possible, likebuilding and running an executable that uses the headers and links against a packaged libraryshould be enough. Such execution should be as simple as possible too. Any kind ofunit and functional tests should be done in the build() method.

  • All input sources must be common for all binary configurations: All the “source” inputs, including the conanfile.py, the conandata.yml, the exports and exports_source, the source() method, patches applied in the source() method, cannot be conditional to anything, platform, OS or compiler, as they are shared among all configurations. Furthermore, the line endings for all these things should be the same, it is recommended to use always just line-feeds in all platforms, and do not convert or checkout to crlf in Windows, as that will cause different recipe revisions.

  • Keep ``python_requires`` as simple as possible. Avoid transitive python_requires, keep themas reduced as possible, and at most, require them explicitly in a “flat” structure, withoutpython_requires requiring other python_requires. Avoid inheritance (via python_requires_extend)if not strictly necessary, and avoid multiple inheritance at all costs, as it is extremelycomplicated, and it does not work the same as the built-in Python one.

  • At the moment the Conan cache is not concurrent. Avoid any kind of concurrency or parallelism,for example different parallel CI jobs should use different caches (with CONAN_HOME env-var). This mightchange in the future and we will work on providing concurrency in the cache, but until then,use isolated caches for concurrent tasks.

  • Avoid ‘force’ and ‘override’ traits as a versioning mechanism. The force and override traits tosolve conflicts are not recommended as a general versioning solution, just as a temporary workaround to solvea version conflict. Its usage should be avoided whenever possible, and updating versions or version ranges inthe graph to avoid the conflicts without overrides and forces is the recommended approach.

  • Please, do not abuse ‘tool_requires’. Those are intended only for executables like cmake and ninja running in the “build”context, not for libraries or library-like dependencies, that must use requires or test_requires.

Forbidden practices

  • Conan is not re-entrant: Calling the Conan process from Conan itself cannot be done. That includes callingConan from recipe code, hooks, plugins, and basically every code that already executes whenConan is called. Doing it will result in undefined behavior. For example it is not validto run conan search from a conanfile.py. This includes indirect calls, like runningConan from a build script (like CMakeLists.txt) while this build script is already beingexecuted as a result of a Conan invocation. For the same reason Conan Python API cannot be used from recipes: The Conan Python API can only be called from Conan custom commands or from user Python scripts,but never from conanfile.py recipes, hooks, extensions, plugins, or any other codeexecuted by Conan.

  • Settings and configuration (conf) are read-only in recipes: The settings and configuration cannot be defined or assigned values in recipes. Something like self.settings.compiler = "gcc" in recipes shouldn’t be done. That is undefined behavior and can crash at any time, or just be ignored. Settings and configuration can only be defined in profiles, in command line arguments or in the profile.py plugin.

  • Recipes reserved names: Conan conanfile.py recipes user attributes and methods should always start with _.Conan reserves the “public” namespace for all attributes and methods, and _conan forprivate ones. Using any non-documented Python function, method, class, attribute, even ifit is “public” in the Python sense, is undefined behavior if such element is not documentedin this documentation.

  • Conan artifacts are immutable: Conan packages and artifacts, once they are in the Conan cache, they are assumed to be immutable.Any attempt to modify the exported sources, the recipe, the conandata.yml or any of the exportedor the packaged artifacts, is undefined behavior. For example, it is not possible to modify thecontents of a package inside the package_info() method or the package_id() method, thosemethods should never modify, delete or create new files inside the packages. If you need to modifysome package, you might use your own custom deployer.

  • Conan cache paths are internal implementation detail: The Conan cache paths are an internal implementation detail. Conan recipes provide abstractionslike self.build_folder to represent the necessary information about folders, and commandslike conan cache path to get information of the current folders. The Conan cache mightbe checked while debugging, as read-only, but it is not allowed to edit, modify or deleteartifacts or files from the Conan cache by any other means that Conan command line or public API.

  • Sources used in recipes must be immutable. Once a recipe is exported to the Conan cache, it is expected that the sources are immutable, that is, that retrieving the sources in the future will always retrieve the exact same sources. It is not allowed to use moving targets like a git branch or a download of a file that is continuously rewritten in the server. git checkouts must be of an immutable tag or a commit, and download()/get() must use checksums to verify the server files doesn’t change. Not using immutable sources will be undefined behavior.

Core guidelines — conan 2.4.0 documentation (2024)

References

Top Articles
Lonadine
Princetoby69
Mvd Eagle Ranch Appointment
Bez.talanta Leaks
ᐅ eGirl Kleidung kaufen: Wie ein eGirl aussehen so funktionierts!
Air Chat En Espanol
Order Irs Tax Forms Online
Superhot Unblocked Games
A Comprehensive Guide to Redgif Downloader
Zenuwbeknelling in de voorvoet (Mortons neuroom)
Craigslist Carroll Iowa
Unlockme Cintas
Schmidt & Schulta Funeral Home Obituaries
8 Internet Celebrities who fell prey to Leaked Video Scandals
Dallascowgirl Leaked Of
73 87 Chevy Truck Air Conditioning Wiring Diagram
Wvtm 13 Schedule
Dmv Leestown Rd
Onlybaddiestv
How Much Is Cvs Sports Physical
Myzynrewards
Cal Poly San Luis Obispo Catalog
Gina's Pizza Port Charlotte Fl
Pole Barns 101: Everything You Need to Know - Big Buildings Direct
Server - GIGABYTE Costa Rica
Ok Google Zillow
My Eschedule Greatpeople Me
Takeaways from AP's report updating the cult massacre that claimed hundreds of lives in Kenya
Receive Sms Verification
Craigslist Chicagoland Area
How to get tink dissipator coil? - Dish De
Huadu Cn Fedex
Find The Eagle Hunter High To The East
How To Get Coins In Path Of Titans
Guide for The Big Con
Windows 10 Defender Dateien und Ordner per Rechtsklick prüfen
Cooktopcove Com
Krunker.io . Online Games . BrightestGames.com
Facebook Marketplace Winnipeg
99 Cents Food Handler
Cashtapp Atm Near Me
Upc 044376295592
R/Moissanite
Alles, was ihr über Saison 03 von Call of Duty: Warzone 2.0 und Call of Duty: Modern Warfare II wissen müsst
Directions To 401 East Chestnut Street Louisville Kentucky
Zmeenaorrxclusive
Used Vehicles for Sale near Grandville, MI 49418 | U-Haul
Uncc Class Schedule
Braveheart Parents Guide
Basketball Stars Unblocked Games Premium
2045 Union Ave SE, Grand Rapids, MI 49507 | Estately 🧡 | MLS# 24048395
Halloween 1978 Showtimes Near Movie Tavern Little Rock
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 5356

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.