question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a clean way to access the conan database from a recipe?

See original GitHub issue

To help us debug your issue please explain:

  • [ x ] I’ve read the CONTRIBUTING guide.
  • [ x ] I’ve specified the Conan version, operating system version and any tool that can be relevant.
  • [ x ] I’ve explained the steps to reproduce the error or the motivation/use case of the question/suggestion.

I have the issue that I want to access data from a generic repository on the same artifactory as the conan repository. Therefore currently I have added this dirty workaround:

        def getConanDatabase(self):
            color = colorama_initialize()
            out = ConanOutput(sys.stdout, sys.stderr, color)
            user_home = get_conan_user_home()
            base_folder = os.path.join(user_home, ".conan")

            cache = ClientCache(base_folder, out)
            localdb = LocalDB.create(cache.localdb)
            return localdb

# some other code

        user, token = self._conanDB.get_login(self.conanURL) 

        head = {'Authorization': "Bearer %s" % str(token)}
        try:
            tools.get(fullUrl, destination=self._test_data_folder,
                      headers=head)
        except ConanException as ex:
            print("Raw Data Loading Error: ", ex)

While this works good in the current situation I assume that there is a high probability that this will break in the future due to conan updates and the fact that I just hijacked the necessary conan functions to access this database. Is there currently a better way to achive the same thing?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
memshardedcommented, Sep 26, 2019

Of course if there would be a way for the get function to just use known authentication for a already known base url this would be the most convenient solution.

The problem I see with this solution, is that this is not necessarily always true. Different repos can have different access policies, permissions, etc., so the token available for Conan might not work for a generic repo or viceversa. We could have a deeper look, but if the solution is not general enough, then implementing it as a built-in, is not possible. Same applies for reading the token directly from the local DB, that token still might not be valid for a generic repo, so enabling reading the DB token still feels a bit hacky, even if the access was simplified.

I think that if I had to do it, I’d try to be pragmatic and keep it as simple as possible, have just some read-only credentials for that test generic repo, and pass them in env-var.

Another alternative would be to create conan packages with those files inside, that would have some beneficial advantages, for example if you are using the same data as test input for different packages, that would be cached in the conan cache, saving tons of download time. Have you considered this approach?

0reactions
memshardedcommented, Oct 1, 2019

To sum it up there is no clean way to access an access token and most likely there won’t be one in the near future.

Yes, I am afraid that is the case, seems a complicated thing with too many potential corner cases.

If you are going to try wrapping them in packages that can be used as build-requires, that sounds good. Let us know how it goes and if you have any further question. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods — conan 1.44.1 documentation
This method is used to build the source code of the recipe using the desired commands. You can use your command line tools...
Read more >
Conan Repositories - JFrog - JFrog Documentation
Once the Conan client is installed, you can access Conan repositories in Artifactory through its command line interface.
Read more >
Conan packages in the Package Registry - GitLab Docs
conan /data to clean up the packages stored in the cache. Remove a Conan package. There are two ways to remove a Conan...
Read more >
Repository clean up - cmake - Stack Overflow
No it is not possible, even if recipes have access to self.source_folder , self.build_folder , etc., it would violate all decoupling and ...
Read more >
Let's Build Chuck Norris! - Part 2: SQLite and conan - dmerej.info
In the conan world, any user can publish recipes and binary packages for any library. (Many package managers use a “first come, first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found