Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 5.59 KB

v2_linter.md

File metadata and controls

71 lines (55 loc) · 5.59 KB

Linter to help migration to Conan v2

Contents

On our path to Conan v2 we are leveraging on custom Pylint rules. This linter will run for every pull-request that is submitted to the repository and will raise some warnings and errors that should be addressed in order to migrate the recipes to Conan v2.

It is important to note that these rules are targeting Conan v2 compatibility layer, their purpose is to fail for v1 syntax that will be no longer available in v2. Even if the syntax if perfectly valid in Conan v1, the recipe might fail here because it is not v2-compliant.

Note Some of the errored checks might be just plain Python syntax errors, while others might be related to the custom rules added by us.

Here you can find some examples of the extra rules we are adding:

Running the linter locally

Check the Developing Recipes for details.

Import ConanFile from conan

The module conans is deprecated in Conan v2. Now all the imports should be done from module conan:

from conan import ConanFile

Import tools from conan

All v2-compatible tools are available in module conan.tools under different submodules. Recipes should start to import their tools from this new module. Some of the new tools accept new argument, please, check the Conan documentation.

Here is a list of different imports and their new equivalent (note that the interface for most of this functions changed, see their respective link to the documentation):

Conan v1 Conan v2 Required Conan Version
conans.tools.get conan.tools.files.get 1.41.0
conans.tools.download conan.tools.files.download 1.41.0
conans.tools.rmdir conan.tools.files.rmdir 1.47.0
conans.tools.patch conan.tools.files.patch 1.35.0
conans.tools.remove_files_by_mask conan.tools.files.rm 1.50.0
conans.copy conan.tools.files.copy 1.46.0
conans.tools.load conan.tools.files.load 1.35.0
conans.tools.save conan.tools.files.save 1.35.0
conans.tools.rename conan.tools.files.rename 1.37.0
conans.tools.replace_in_file conan.tools.files.replace_in_file 1.46.0
conans.tools.mkdir conan.tools.files.mkdir 1.35.0
conans.tools.chdir conan.tools.files.chdir 1.40.0
conans.tools.unzip conan.tools.files.unzip 1.46.0
conans.tools.collect_libs conan.tools.files.collect_libs 1.46.0
conans.tools.Version conan.tools.scm.Version 1.46.0
conans.tools.sha256sum conan.tools.files.check_sha256 1.46.0
conans.tools.unix_path conan.tools.microsoft.unix_path 1.47.0
conans.tools.is_apple_os conan.tools.apple.is_apple_os 1.51.3
conans.tools.cpu_count conan.tools.build.build_jobs 1.43.0
conans.tools.check_min_cppstd conan.tools.build.check_min_cppstd 1.50.0
conans.tools.cross_building conan.tools.build.cross_building 1.46.0
conans.errors.ConanInvalidConfiguration conan.errors.ConanInvalidConfiguration 1.47.0
conans.errors.ConanException conan.errors.ConanException 1.47.0