I have a lot conan recipe files in the below format (the name of class in each of the conanfile.py
is different)
conanfile.py
is as below
from conans import ConanFile, CMake, tools
import os
from conan_settings import MySettings
class MyConan(ConanFile):
"""SW package conan class."""
name = "check"
description = "<Dummy>"
license = MySettings.LICENSE
url = MySettings.URL
exports = "conan_settings.py"
settings = "os", "arch", "compiler"
# Add smart base logic
python_requires = MySettings.base_class
python_requires_extend = "smart.smartBase"
options = MySettings.options
default_options = MySettings.default_options
def source(self):
"""Conan source method."""
git = tools.Git()
output = git.clone(self.url)
self.output.info("Source: %s" % output)
def requirements(self):
"""Load requirements."""
for entry in MySettings.requirements:
self.requires(entry)
def build_requirements(self):
"""Load build requirements."""
for entry in MySettings.test_requirements:
self.test_requires(entry)
def _configure_cmake(self, definitions: dict = {}):
"""CMake configure."""
cmake = CMake(self)
cmake.definitions.update(definitions)
cmake.configure(source_folder=".", build_folder=self._build_dir)
return cmake
def build(self):
"""CMake build the package."""
cmake = self._configure_cmake()
cmake.install()
def package(self):
"""Package all artifacts."""
self.copy("*", src=self._bin_dir,
excludes=('**/test/*', '**/tests/*', 'test/*'))
self.copy(os.path.join("share", "test", "*"), src=self._bin_dir)
The conan_settings.py
is as below
class MySettings:
"""Conan settings class."""
CONAN_USER = 'smart-ci'
LICENSE = 'proprietary'
URL = 'https://abc.def.com/SMART/_git/check'
# conan base class requirement
base_class = f'foobar/2.0.0@{CONAN_USER}/stable'
# conan requirements
requirements = [
f'baz/[>=1 <=3]@{CONAN_USER}/stable',
f'jam/[>=4 <=7]@{CONAN_USER}/stable',
]
test_requirements = [
f'dummy/[~1.12.8]@{CONAN_USER}/stable',
f'data/[~1.0.4]@{CONAN_USER}/stable',
]
# options
options = {'DEF_VERSION': ['ert-11']}
default_options = {'DEF_VERSION': 'ert-11'}
For these files, I want to get the requirements that are parsed. How do I achieve that?
The out put expected is
python_requires = 'foobar/2.0.0@smart-ci/stable'
python_requires_extend = "smart.smartBase"
requirements = [ 'baz/[>=1 <=3]@smart-ci/stable',
'jam/[>=4 <=7]@smart-ci/stable' ]
test_requirements = [ 'dummy/[~1.12.8]@smart-ci/stable',
'data/[~1.0.4]@smart-ci/stable', ]
I tried using conan info
but that gives the fixed versions that will be installed & not the ranges as in the recipe files. Can anyone help on how to achieve this?
Another recipe, just to give an idea about the kind of recipe files
conanfile.py
is as below
from conanfile_constants import ConanSettings
from conans import ConanFile
class AnotherConan(ConanFile):
name = "laggy-platform"
description = "laggy platform implementation"
license = ConanSettings.LICENSE
url = ConanSettings.URL
exports = "conanfile_constants.py"
python_requires = (
ConanSettings.regd_CONAN_BASE,
ConanSettings.laggy_CONAN_BASE,
)
python_requires_extend = (
ConanSettings.PYTHON_REQUIRES_EXTEND_BASE,
ConanSettings.PYTHON_REQUIRES_EXTEND_SW,
)
requires = (
ConanSettings.laggy_IPC,
ConanSettings.laggy_BUILD,
ConanSettings.laggy_SAFE_TAR,
ConanSettings.laggy_PLATFORM_IF,
ConanSettings.CORE_TYPES,
ConanSettings.CRYPTO_API,
ConanSettings.STM_PROJECT_IF,
ConanSettings.FLATCFG_LIB,
ConanSettings.LOG_FRAMEWORK_IF,
ConanSettings.EXM_EXECUTIONCLIENT_LIB,
ConanSettings.COM_COMMUNICATION_MANAGER,
ConanSettings.regd_CRC_LIB,
)
def build_requirements(self):
self.test_requires(ConanSettings.FLATBUFFERS)
def package(self):
self.copy("*", src=self._bin_dir, excludes=('tests/*', 'test/*'))
self.copy(pattern=f"deployment-ruleset-{self.name}.yaml", dst="integration", src="integration", keep_path=False)
conanfile_constants.py
is as below
class ConanSettings:
"""Conan settings class."""
CONAN_USER = 'smart-ci'
LICENSE = 'proprietary'
URL = 'https://abc.def.com/SMART/_git/check'
PYTHON_REQUIRES_EXTEND_BASE = "regd-conan-base.regdBase"
PYTHON_REQUIRES_EXTEND_SW = "laggy-conan-base.UcmregdSW"
# pinned versions
regd_CONAN_BASE = f"regd-conan-base/2.0.0@{CONAN_USER}/stable"
laggy_CONAN_BASE = f"laggy-conan-base/1.1.0@{CONAN_USER}/tools"
# variable versions
laggy_BUILD = f"laggy-build/[^1]@{CONAN_USER}/stable"
regd_FS_CLI = f"regd_fs_processor_cli/[^10]@{CONAN_USER}/stable"
laggy_IPC = f"laggy-ipc/[^4]@{CONAN_USER}/stable"
laggy_SAFE_TAR = f"laggy-safe-tar/[^5]@{CONAN_USER}/stable"
laggy_PLATFORM_IF = f"laggy-platform-if/[^3]@{CONAN_USER}/stable"
laggy_SWP_GENERATOR = f"laggy-swp-generator/[^3]@{CONAN_USER}/stable"
regd_CRC_LIB = f"regd_crc_lib/[^3]@{CONAN_USER}/stable"
1