Open sangramjadhavbhtc opened 11 months ago
Hi @sangramjadhavbhtc
Thanks for your report.
auth=("sangram.jadhav", "password")
First, I'd like to start with a recommendation, even if the download()
tool allows passing the auth
, try to use this as the very last resort. Adding credentials in the source files of conanfile.py
recipes is a high risk. There are several other ways to approach this:
git clone
of the repo, instead of downloading the sourcesource_credentials.json
file, check https://docs.conan.io/2/reference/config_files/source_credentials.html, to put credentials instead of putting them in conanfiles.Of course, it would be good to validate that you have the right credentials, can you download that file with a wget
or curl
command using that user/password? This would be the first thing to try.
@memsharded Thank you for attending to my issue and valuable suggestions.
can we control the downloads? A specific person can download the file from a remote repo. (in my case bitbucket) using conan.
and one more question what is the "data" in this command; get(self, data["url"], sha256=data["sha256"], strip_root=data["strip_root"])
I have also tried this :
get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"])
but getting error:
C:\Users\sangram.jadhav\~~\Source handle\handle_sources>conan source .
conanfile.py (hello/4.0.1): Calling source() in C:\Users\sangram.jadhav\~\Source handle\handle_sources
ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 14
get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"]) ConanException: Cannot deduce file name from the url: 'https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip'. Use 'filename' parameter.
can we control the downloads? A specific person can download the file from a remote repo. (in my case bitbucket) using conan.
With exactly the same credentials? It should be good to verify in your machine that you are trying it is possible with those credentials, to rule out other possible credentials, machine-setup or system configurations issues.
The second error is expected and the error message is giving a hint Use 'filename' parameter.
. As the URL is complex, it cannot deduce the filename to download, so it needs the filename=xxxx
parameter.
@memsharded
The second error is expected and the error message is giving a hint
Use 'filename' parameter.
. As the URL is complex, it cannot deduce the filename to download, so it needs thefilename=xxxx
parameter.
you mean to say like this?
get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], filename="myrepo123.zip", sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"])
filename="myrepo123.zip",
Now It is showing AuthenticationException
ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 14 get(self, ["https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip"], filename="myrepo123.zip", sha256=["aa757cdc0f1412ed020b115e294103a6180a31f3316b76d63b678c0305063a2c"], strip_root=["strip_root"]) AuthenticationException:
Along with conanfile, the source_credentials.json file is also added in the same folder. Still facing issue of AuthenticationException
source_credentials.json: { "credentials": [ { "url": "https://bitbucket.bhtc.com/users/sangram.jadhav/repos/conan_trail/browse", "user": "sangram.jadhav", "password": "password" } ] }
Along with conanfile, the source_credentials.json file is also added in the same folder.
That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?
Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your url
in source_credentials.json
is wrong.
I'd still like to see a curl or wget command that successfully download the file in the computer, without using Conan. We need to rule out other potential factors.
That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?
No, I don't know how to add data directly to the cache. only exports_sources = is known to me.
Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your
url
insource_credentials.json
is wrong.
Now, the Same links are filled at both places but still not working
{ "credentials": [ { "url": "https://bitbucket.~.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip", "user": "sangram.jadhav", "password": "password" } ] }
I'd still like to see a curl or wget command that successfully download the file in the computer, without using Conan. We need to rule out other potential factors.
I am using a Windows machine for development. is curl useful in this case?
No, I don't know how to add data directly to the cache. only exports_sources = is known to me.
These are some useful resources to learn:
conan config home
gives you the folder of the cache: https://docs.conan.io/2/reference/commands/config.html#conan-config-homeconan config install
command can help to distribute and share Conan configuration, like remotes, settings, profiles, etc)It is not the same link. It is the same base URL of the domain to cover with the credentials.
I am using a Windows machine for development. is curl useful in this case?
yes, you can get curl
for example if using cmder
or it is possible to install curl in Windows too
Along with conanfile, the source_credentials.json file is also added in the same folder.
That files does not go in the same folder, it has to be in the Conan cache, did you add it to the Conan cache?
Oh, understood, it is a conan home folder. source_credentials.json is added in conan cache.
Also the URL is wrong, you should be using the same URL root that you use in your conanfile.py, otherwise it will not match and it will not use the credentials. Your
url
insource_credentials.json
is wrong.
Just for the feedback; these are the changes I have made. But, the result is the same as the previous.
yes, you can get curl for example if using cmder or it is possible to install curl in Windows too
Ok I will try this. Thank you
I am afraid the url is still wrong, it needs to include the protocol. Please check the examples in https://docs.conan.io/2/reference/config_files/source_credentials.html, they all include the protocol.
Trying conan.tools.files.download() from https://docs.conan.io/2/reference/tools/files/downloads.html but facing issue
Error:
C:\Users\sangram.jadhav\handle_sources>conan source .
conanfile.py (hello/4.0.1): Calling source() in C:\Users\sangram.jadhav\~~\Source handle\handle_sources
ERROR: conanfile.py (hello/4.0.1): Error in source() method, line 32
download(self, "https://bitbucket.bhtc.com/rest/api/latest/projects/~SANGRAM.JADHAV/repos/conan_trail/archive?at=refs%2Fheads%2FZlib_Lib&format=zip", "myrepo123.zip", auth=("sangram.jadhav", "XYZ"))
AuthenticationException:
Conanfile:
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import copy, get, download, unzip, check_sha1
class helloRecipe(ConanFile):
name = "hello"
version = "4.0.1"