Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] approvaltests.cpp/10.13.0: conanfile is not compatible with mirror urls #26683

Open
markuspi opened this issue Feb 24, 2025 · 0 comments · May be fixed by #26687
Open

[package] approvaltests.cpp/10.13.0: conanfile is not compatible with mirror urls #26683

markuspi opened this issue Feb 24, 2025 · 0 comments · May be fixed by #26687
Labels
bug Something isn't working

Comments

@markuspi
Copy link

Description

The recipe file of approvaltests.cpp has hardcoded logic that assumes only one source url is present per file. This breaks our downstream automation, where we modify conandata.yml file to add custom mirror urls.

def source(self):
for source in self.conan_data["sources"][self.version]:
url = source["url"]
filename = url[url.rfind("/") + 1:]
download(self, url, filename, sha256=source["sha256"])
rename(self, src=os.path.join(self.source_folder, f"ApprovalTests.v.{self.version}.hpp"),
dst=os.path.join(self.source_folder, self._header_file))

Judging by conan's source code of conan.tools.files.get and .download, I assume a possible fix could be:

         urls = source["url"]
         url = urls[0] if isinstance(urls, (list, tuple)) else urls
         filename = url[url.rfind("/") + 1:] 

Package and Environment Details

  • Package Name/Version: approvaltests.cpp/10.13.0
  • Conan version: conan 1.66.0

Conan profile

n/a

Steps to reproduce

  • download approvaltests.cpp/10.13.0 conanfile.py and conandata.yml
  • edit conandata.yml, adding (valid) mirror urls, i.e.:
10.13.0:
  - sha256: c00f6390b81d9924dc646e9d32b61e1e09abda106c13704f714ac349241bb9ff
    url:
    - https://internal/approvaltests.cpp/10.13.0/ApprovalTests.v.10.13.0.hpp
    - https://github.com/approvals/ApprovalTests.cpp/releases/download/v.10.13.0/ApprovalTests.v.10.13.0.hpp
  - sha256: c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4
    url:
    - https://internal/approvaltests.cpp/10.13.0/LICENSE
    - https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/v.10.13.0/LICENSE
  • try to build the package, observe error

Logs

Click to expand log

Building the package with the updated conandata.yml results in the following error:

ERROR: approvaltests.cpp/10.13.0: Error in source() method, line 80
	filename = url[url.rfind("/") + 1:]
	AttributeError: 'list' object has no attribute 'rfind'
@markuspi markuspi added the bug Something isn't working label Feb 24, 2025
@markuspi markuspi linked a pull request Feb 25, 2025 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant