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.

[question] how do i get the path to the exported or installed package in cache?

See original GitHub issue

Hi,

I would like to know the path in the cache to the package folder of a given package name and id.

For example:

/home/someuser/.conan/data/my-package-name/0.2.1/user/channel/package/e106f0e3de7fc8e9a057009394741ef4441857ec/

I tried with reconstructing the path but on windows, or with short/long path, it makes it hard to rebuild.

I would like a command or a python function to call that would take the package full name and the package id and it returns me the path to the package folder in cache.

It seems like ConanApi.get_path does the job but I don’t know how to call it from my script?

conan info does not return this information for a given package id, or I cannot get it work:

conan info my-package-name/0.2.1@user/channel:e106f0e3de7fc8e9a057009394741ef4441857ec

it does not work with package id

Gaetan

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
MihaiPopescu1985commented, Oct 25, 2022

conan info --paths --package-filter my_package/1.0.0@mine/org --only “package_folder” C:\path\to\my\recipe\that\uses\this\package\conanfile.py

0reactions
gsemetcommented, Apr 29, 2021

I fixed my use case by implementing the following function in my Conan wrapper :


import pathlib

from conans.client.conan_api import ConanAPIV1
from conans.client.tools.win import unix_path
from conans.model.ref import ConanFileReference
from conans.model.ref import PackageReference

def get_package_folder_in_cache(package_name: str, package_id: str) -> pathlib.Path:
    conan_api = ConanAPIV1()
    conan_api.create_app(quiet_output=False)
    ref = ConanFileReference.loads(package_name)
    package_layout = conan_api.app.cache.package_layout(ref, short_paths=None)

    pref = PackageReference(
        package_layout._ref, package_id  # pylint: disable=protected-access
    )
    pkg_folder = package_layout.package(  # pylint: disable=assignment-from-no-return
        pref
    )
    return pathlib.Path(unix_path(pkg_folder))

I know it is not elegant and may break at any time, but this is the only way I found to fetch the real package folder using the same layout mechanism that what conan actually use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where is pip cache folder? - python - Stack Overflow
The location of the cache directory can be changed via the command line option --cache-dir . Share.
Read more >
Where are packages stored installed with APT in Ubuntu 16.04?
When I tried to find packages in /var/cache/apt/archives , there are no packages. Where are they stored if it's not in this directory?...
Read more >
BiocFileCache: Managing File Resources Across Sessions
If the path location exists and has been utilized to store files previously, the previous object will be loaded with any files saved...
Read more >
Caching in GitLab CI/CD
Locally, under the gitlab-runner user's home directory: /home/gitlab-runner/cache/<user>/<project>/<cache-key>/cache.zip . Docker, Locally, under Docker volumes ...
Read more >
Managing packages - Tanium Documentation
View package details ... From the Main menu, go to Administration > Content > Packages. The Packages grid displays most of the attributes...
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