Conan: [question] conan conandata.yml sources url not support file:// local or remote

Created on 1 Feb 2020  路  6Comments  路  Source: conan-io/conan

I try to change conandata.yml sources download url to local file for testing, it seen to not working.
tools.get(**self.conan_data["sources"][self.version]) shoud support file: mode to local or remote file.
eg:
linux: file:/home/user/sources/conan.tar.gz
windows: file:C:\Users\Home\sources/conan.tar.gz

tools download should be based on protocol:
protocol://host:port/path?query#fragment
protocol: http: https: ftp: file: packagepath:
if without protocol, default use local package path file .

medium low queue feature

Most helpful comment

especially for testing, this feature is really appreciated. So I don't need to download a big source file from some server.

All 6 comments

The problem with that is that conandata.yml should be machine undependable. conandata is executed on _each_ build, not on export.
If a user installs your recipe and its conandata points somewhere locally - there is a huge chance that they wouldn't get the result they want.

There are 2 different things here:

  • conandata.yml is actually agnostic, it doesn't contain any logic regarding those sources, just a dict of values. conandata is written at export / create time, and loaded every time the conanfile.py is loaded.
  • The conandata is used in the source() method if it is explicitly used in tools.get() or tools.download() or any other logic.
  • The one not supporting the different protocols is tools.get(). But this is totally unrelated to conandata.yml. If you explicitly pass a ftp: url to tools.get() it will also fail.

So this is a feature request that tools.get() support different protocols. I guess this is doable, we already have a ftp_download helper, and the file: would be a copy. Probably deserves yet another level of access, and implement a tools.xxx_download() that can receive different protocols. Because tools.get() does other things like unzipping, etc, maybe not always desired.

This feature makes sense, but it doesn't look like a high priority. If necessary, users can implement the logic in the source() method easily.

especially for testing, this feature is really appreciated. So I don't need to download a big source file from some server.

hitting the exact same requirements trying to build gtest with local tarball :)

especially for testing, this feature is really appreciated. So I don't need to download a big source file from some server.

Regarding the download of big files from server, repeated times, now there is the file download cache, which can work across multiple Conan homes, and that will avoid downloading the same file multiple times from external servers: https://docs.conan.io/en/latest/configuration/download_cache.html

Not saying that this is a solution to the different protocols, but maybe it can alleviate some pain too.

Was this page helpful?
0 / 5 - 0 ratings