Is there a clean way to access the conan database from a recipe?
See original GitHub issueTo 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:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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?
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!