Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] conan 2.0 tool requires via GraphApi #17686

Open
1 task
ovaar opened this issue Feb 3, 2025 · 1 comment
Open
1 task

[question] conan 2.0 tool requires via GraphApi #17686

ovaar opened this issue Feb 3, 2025 · 1 comment
Assignees

Comments

@ovaar
Copy link

ovaar commented Feb 3, 2025

What is your question?

Hi! I'm trying to retrieve all requirements of a recipe using the python GraphAPI in an offline environment, meaning that I have all remotes disabled.

Now for example, take gsoap/2.8.134, which requires:

  • openssl (requires)
  • zlib (requires)
  • winflexbison (tool_requires)

The problem is that this command does not include winflexbison, because it always tries to retrieve that dependency through a remote, but that is not what I want. Instead I would like to get the graph of all the dependencies while not having to connect to an remote, because if I do allow connections to the conancenter remote, the tool_requirement(winflexbison) is automatically resolved and downloaded to the conan cache.

Is there a way to still get the dependency graph without having to have a remote enabled ?

 def get_dependencies(self, conan_api: ConanAPI = ConanAPI(), allow_remote_download=True):
        remote = conan_api.remotes.get("conancenter")
        profile = conan_api.profiles.get_profile(
            [str(_ROOT_ / self.profile_file_name)],
        )
        deps_graph = conan_api.graph.load_graph_consumer(
            path=str(self.recipe_path.resolve()),
            name=self.pkg_name,
            version=self.rev,
            user=None,
            channel=None,
            profile_host=profile,
            profile_build=profile,
            lockfile=None,
            remotes=[remote],
            update=False,
            check_updates=False,
        )
        serialized = deps_graph.serialize()
        pprint(serialized)

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded memsharded self-assigned this Feb 3, 2025
@memsharded
Copy link
Member

Hi @ovaar

Thanks for your question.

The problem is that this command does not include winflexbison, because it always tries to retrieve that dependency through a remote, but that is not what I want. Instead I would like to get the graph of all the dependencies while not having to connect to an remote, because if I do allow connections to the conancenter remote, the tool_requirement(winflexbison) is automatically resolved and downloaded to the conan cache.

yes, by default Conan resolves the full dependency graph, including tool_requires and test_requires for "recipes", not binaries. That means, that it download only the recipes, to guarantee things are at least reproducible, and that is very fast because recipes are small. Then it will avoid downloading the heavy binaries if not really necessary to build from source.

So the recommended way would be to have the tool_requires recipes including flexbison for example, local, in the same way you already have the other recipes like zlib or openssl downloaded locally (otherwise it would fail to work, because you don't have remotes).

There is also the possibility, for some cases, to fully skip the resolution of tool_requires and test_requires, using the configuration tools.graph:skip_build and tools.graph:skip_test. Note that if there are some recipe that really needs the tool_requires, it will raise an exception, but if not, this might be what you are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants